Skip to content

Conversation

@adamhooper
Copy link
Contributor

Relates to QZ-151 in that I tried calling <Button> from typescript and this error appeared.

It looks like "inactive" might have been removed in error. qz-react uses it in seven different calls.

It's used all over qz-react. It was removed in #24 without any
explanation. Seems like an oversight.
@linear
Copy link

linear bot commented Aug 23, 2021

QZ-151 Social-login buttons submit the form

Steps to reproduce:

  1. Open https://qz.com/login/
  2. Enter username/password
  3. Click "Log in with Apple ID"

Expected results: the button click opens the 'Apple ID' popup

Actual results: the button click opens the 'Apple ID' popup and logs you in

This is because a <button> is a "submit" button by default; we need to set type="button" (or move it outside the form) to prevent that.

@adamhooper adamhooper requested a review from Bhammy August 23, 2021 20:24
* element.
*/
onClick: PropTypes.func.isRequired,
onClick?: React.UIEventHandler<HTMLButtonElement>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm - why make onClick optional? It seems like a useful pointer to say that maybe another kind of element is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A <button type="submit"> doesn't need (and shouldn't have) an onClick.

I think this nit should be obvious when calling the component. But when I converted to Typescript, I erroneously set this to "required" and then had to backtrack when the callers threw type-safety errors. So I've added an inline comment to save the next developer the same embarrassment.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦 of course! Good points.

@adamhooper adamhooper merged commit 52aea2b into main Aug 24, 2021
@adamhooper adamhooper deleted the feature/qz-151-inactive-buttons branch August 24, 2021 14:14
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.

4 participants