-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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(Checkbox): match DOM checkbox behavior #2748
Conversation
src/modules/Checkbox/Checkbox.js
Outdated
> | ||
<input | ||
{...htmlInputProps} | ||
checked={checked} | ||
className='hidden' | ||
id={id} | ||
name={name} | ||
onClick={this.handleInputClick} | ||
onChange={this.handleInputClick} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relevant change, remove duplicate click firing.
onChange={this.handleContainerClick} | ||
onMouseDown={this.handleMouseDown} | ||
onMouseUp={this.handleMouseUp} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relevant change
_.invoke(this.props, 'onMouseUp', e, { ...this.props, checked: !!checked, indeterminate: !!indeterminate }) | ||
|
||
this.handleClick(e) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relevant change, click is fired on mouse up.
* @param {object} data - All props and current checked/indeterminate state. | ||
*/ | ||
onMouseUp?: (event: React.MouseEvent<HTMLInputElement>, data: CheckboxProps) => void; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relevant change
I've checked this branch,
|
…React into fix/checkbox-spacebar Signed-off-by: Oleksandr Fediashov <[email protected]> # Conflicts: # docs/app/Examples/modules/Checkbox/States/CheckboxExampleRemoteControl.js # docs/app/Examples/modules/Checkbox/States/index.js # docs/app/Examples/modules/Checkbox/Usage/CheckboxExampleRemoteControl.js # docs/src/examples/modules/Checkbox/States/CheckboxExampleRemoteControl.js # src/modules/Checkbox/Checkbox.d.ts # src/modules/Checkbox/Checkbox.js
Signed-off-by: Oleksandr Fediashov <[email protected]>
…React into fix/checkbox-spacebar
Signed-off-by: Oleksandr Fediashov <[email protected]>
Signed-off-by: Oleksandr Fediashov <[email protected]>
….com/Semantic-Org/Semantic-UI-React into fix/checkbox-spacebar
Signed-off-by: Oleksandr Fediashov <[email protected]>
Signed-off-by: Oleksandr Fediashov <[email protected]>
Signed-off-by: Oleksandr Fediashov <[email protected]>
Signed-off-by: Oleksandr Fediashov <[email protected]>
@levithomason I've fixed tests and replaced some of them with new, also updated example. There is a single failing conformance test. I think that we can disable it all, what you think? |
Codecov Report
@@ Coverage Diff @@
## master #2748 +/- ##
==========================================
+ Coverage 99.89% 99.89% +<.01%
==========================================
Files 170 170
Lines 2801 2806 +5
==========================================
+ Hits 2798 2803 +5
Misses 3 3
Continue to review full report at Codecov.
|
I've fixed the last broken test. The Checkbox now has full parity with the HTML checkbox. See the new example for confirmation: http://localhost:3000/modules/checkbox/#usage-dom-comparison The onChange, onClick, onMouseDown, and onMouseUp events are fired in the same order and with the same arguments as a vanilla HTML checkbox. |
Fixes #2587
A controlled Checkbox did not fire onClick / onChange when pressing spacebar after focus. This was strictly when a functional state updater was used.
Changes
I've commented on relevant changes to help separate the prettier updates from the actual code changes.
TODO
Help much appreciated! Make PRs against
fix/checkbox-spacebar
instead of master.