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… #21165

Merged
merged 1 commit into from Jan 31, 2020
Merged

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

merged 1 commit into from Jan 31, 2020

Conversation

nicu-chiciuc
Copy link
Contributor

🤔 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… Jan 31, 2020
@auto-add-label auto-add-label bot added the bug label Jan 31, 2020
@codesandbox-ci
Copy link

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 d283b81:

Sandbox Source
antd reproduction template Configuration

@codecov
Copy link

codecov bot commented Jan 31, 2020

Codecov Report

Merging #21165 into 3.x-stable will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           3.x-stable   #21165   +/-   ##
===========================================
  Coverage       97.82%   97.82%           
===========================================
  Files             286      286           
  Lines            7754     7754           
  Branches         2185     2185           
===========================================
  Hits             7585     7585           
  Misses            169      169
Impacted Files Coverage Δ
components/modal/ActionButton.tsx 90% <ø> (ø) ⬆️
components/modal/Modal.tsx 100% <ø> (ø) ⬆️

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 bba87d4...d283b81. Read the comment docs.

@afc163 afc163 merged commit da3540b into ant-design:3.x-stable Jan 31, 2020
@nicu-chiciuc nicu-chiciuc deleted the ok-button-props-anchor branch January 31, 2020 14:12
@afc163 afc163 mentioned this pull request Feb 3, 2020
afc163 pushed a commit that referenced this pull request 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

2 participants