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(buttons): fix onClick bug #1118

Merged
merged 1 commit into from
Oct 21, 2019
Merged

fix(buttons): fix onClick bug #1118

merged 1 commit into from
Oct 21, 2019

Conversation

montezume
Copy link
Contributor

@montezume montezume commented Oct 21, 2019

Summary

If the button is NOT disabled, then we should check that onClick exists before calling it 🤦‍♂

This usually affects link buttons.

@montezume montezume requested a review from jonnybel October 21, 2019 13:35
@montezume montezume added the 🐛 Type: Bug Something isn't working label Oct 21, 2019
@@ -73,7 +73,7 @@ describe('rendering', () => {
describe('when using "linkTo"', () => {
it('should navigate to link when clicked', async () => {
const { getByLabelText, history } = render(
<SecondaryButton {...props} linkTo="/foo/bar" />
<SecondaryButton {...props} onClick={null} linkTo="/foo/bar" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test failed in same way as the current issues in MC-FE before making the code change 👍

@montezume montezume self-assigned this Oct 21, 2019
@montezume montezume merged commit f6b7808 into master Oct 21, 2019
@montezume montezume deleted the ml-link-button-fix branch October 21, 2019 13:40
Copy link
Contributor

@jonnybel jonnybel left a comment

Choose a reason for hiding this comment

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

I'm thinking if, when disabled, we could still have handleClick return a dull function for onClick which just does () => null. Could that save us from some of the failing tests?

@montezume
Copy link
Contributor Author

I think the failing tests were due to onClick being undefined and not being disabled.

@jonnybel
Copy link
Contributor

Hmm yeah, I didn't understand it correctly before 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants