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

[EuiButtonGroup] pass a type of button when rendering a button for button group button #4368

Merged
merged 7 commits into from
Dec 9, 2020

Conversation

skerry3000
Copy link
Contributor

@skerry3000 skerry3000 commented Dec 8, 2020

Summary

Attempt to Fix #4360

Not having a type of button was making my button group buttons trigger a form submit on click, since the default type is submit. Enable button group button to take a buttonType prop, which defaults to button and will get passed down to the underlying button.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link

cla-checker-service bot commented Dec 8, 2020

💚 CLA has been signed

@skerry3000 skerry3000 closed this Dec 8, 2020
@skerry3000 skerry3000 reopened this Dec 8, 2020
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ph !! Your proposed changes certainly work, but I think we can optimize a bit more. See comments below.

Comment on lines 122 to 125
/**
* The type of the underlying HTML button
*/
type?: 'button' | 'submit' | 'reset';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we actually need this here because EuiButton extends the HTML button type when it renders as one.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, we might need to add it directly to EuiButtonContentProps so that...

Comment on lines 45 to 49

/**
* The type of the underlying HTML button
*/
buttonType?: 'button' | 'submit' | 'reset';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... this doesn't need to be explicitly added but instead inherited from the extension of EuiButtonContentProps on line 30.

Comment on lines 72 to 73
type = 'button',
buttonType = 'button',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would just mean then that we'd have a conflict of naming with type here, but when looking at the current type prop, it really should probably be called element since it's determining the element to render.

…add type attribute to button content instead of in both button and button group option
@skerry3000
Copy link
Contributor Author

@cchaos Thanks for the feedback! I've attempted to implement it. Let me know what you think.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh sorry, I didn't look to hard at my suggestion. EuiButtonContent doesn't actually do anything with type so I went ahead and moved it back to the EuiButtonGroupOptionProps. I also added it to one of the options in the test suite to check against allowing it to change. 👍

Seems to work well! We'll get this merged once CI passes.

@cchaos
Copy link
Contributor

cchaos commented Dec 9, 2020

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4368/

@cchaos
Copy link
Contributor

cchaos commented Dec 9, 2020

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4368/

@chandlerprall chandlerprall merged commit 07f2f32 into elastic:master Dec 9, 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.

Button Group Buttons Triggering Form Submit After Upgrading
4 participants