Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace NativeButtonProps with ButtonProps for okButtonProps and canc… #22913

Merged
merged 1 commit into from
Apr 6, 2020
Merged

fix: Replace NativeButtonProps with ButtonProps for okButtonProps and canc… #22913

merged 1 commit into from
Apr 6, 2020

Conversation

nicu-chiciuc
Copy link
Contributor

This PR is a copy of a similar PR made for version 3 of the library #21165 so I took the liberty to copy the initial description.

🤔 This is a ...

  • TypeScript definition update

🔗 Related issue link

💡 Background and solution

When trying to use the modal and pass a href to okButtonProps like so:

    Modal.confirm({
      okButtonProps: {
        href: 'www.google.com',
        rel: 'noopener noreferrer',
        target: '_blank',
        style: { marginLeft: '10px' }
      }
    });

TS will raise the error: "Object literal may only specify known properties, and 'href' does not exist in type 'NativeButtonProps'.ts(2322)"

This is because okButtonProps are defined as having the type NativeButtonProps;
The okButtonProps are passed to ActionButton where they also had the type NativeButtonProps;
Then they are passed to Button, in this case Button has the prop type Partial<AnchorButtonProps & NativeButtonProps>;
It seems that it would be correct to allow to change NativeButtonProps with ButtonProps since they also contain definitions in case an anchor props is desired.

📝 Changelog

The changes are pretty straightforward, NativeButtonProps where replaced with ButtonProps in ActionButton.tsx and Modal.tsx.

Language Changelog
🇺🇸 English x
🇨🇳 Chinese

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@nicu-chiciuc nicu-chiciuc changed the title Replace NativeButtonProps with ButtonProps for okButtonProps and canc… fix: Replace NativeButtonProps with ButtonProps for okButtonProps and canc… Apr 3, 2020
@ant-design-bot
Copy link
Contributor

ant-design-bot commented Apr 3, 2020

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 3, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9fee981:

Sandbox Source
antd reproduction template Configuration

@codecov
Copy link

codecov bot commented Apr 3, 2020

Codecov Report

Merging #22913 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22913   +/-   ##
=======================================
  Coverage   98.31%   98.31%           
=======================================
  Files         363      363           
  Lines        7253     7253           
  Branches     1988     1941   -47     
=======================================
  Hits         7131     7131           
  Misses        122      122           
Impacted Files Coverage Δ
components/modal/ActionButton.tsx 90.00% <ø> (ø)
components/modal/Modal.tsx 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18d424e...9fee981. Read the comment docs.

@afc163 afc163 merged commit 1321d90 into ant-design:master Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants