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
removing material from checkbox #1255
Conversation
The visual changes are caused by a bug present in the previous version of the checkbox. |
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.
Summary of things I saw along the way
- Disabled components should not gain the focus:
- The space between label and checkbox should mark as selected the checkbox when clickable. The cursor changes correctly to pointer, but when clicked, doesn't change checkbox's state.
- I think we can take advantage of this refactor and add some more jests tests. For example:
- "Checkbox renders with correct text" is no longer necessary since we have visual tests.
- Check keyboard accessibility.
- Check disabled state (and avoid bugs such as point 1).
- Check correct values for aria attributes and role.
- Check that the value sent in
onSubmit
event is correct. - (Any more tests you can think of)
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.
More comments regarding the component:
- The gap between the label and the checkbox doesn't change the state (hover and active) of the checkbox input.
- Doble click on the label selects the text.
…eact into jialecl-checkbox-withoutMaterial
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.
We missed some functionality:
- With the current implementation, our label checks the checkbox input but doesn't give it the focus. We must implement that, which is how it would work if we had to use the native checkbox input with a label and
htmlFor
property.- Add
onClick
event to the label and give the focus to the checkbox (ref.current.focus();
)
- Add
- Then, we must guarantee that the container, which has the "change value" functionality, doesn't steal the focus from the checkbox. This can be achieved by adding an
onMouseDown
to the main container withevent.preventDefault()
. - And finally, we need to give the focus to the checkbox when he clicks in the gap. This should be as simple as adding
ref.current.focus();
to the change value handler. - With the previous three points, the
handleLabelDblClick
handler should not be necessary. - Optionally, if you want to avoid unnecessary calls to the focus() method, you can check if the checkbox already has the focus, like this:
document.activeElement !== ref?.current
. This should be a problem but may be more precise.
…eact into jialecl-checkbox-withoutMaterial
In regards to this I find it unnecessary, a div without tabIndex=0 is never focusable. |
…eact into jialecl-checkbox-withoutMaterial
Agree! |
…/dxc-technology/halstack-react into jialecl-checkbox-withoutMaterial
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.
One final appointment:
- We need to also test
aria-labelledby
andaria-required
properties.
No description provided.