-
Notifications
You must be signed in to change notification settings - Fork 510
Reimplement Checkbox #6528
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
Reimplement Checkbox #6528
Conversation
9885779 to
0197dca
Compare
|
@ThiefMaster Regarding the failing test, I'm able to suppress it by doing this: diff --git a/indico/web/client/js/react/forms/index.js b/indico/web/client/js/react/forms/index.js
index e5f39b23d1..dce0e902f8 100644
--- a/indico/web/client/js/react/forms/index.js
+++ b/indico/web/client/js/react/forms/index.js
@@ -5,8 +5,10 @@
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.
+import * as fields from './fields';
+
export {handleSubmissionError} from './errors';
-export {
+export const {
FinalCheckbox,
FinalComboDropdown,
FinalDropdown,
@@ -17,7 +19,7 @@ export {
FinalTextArea,
FormFieldAdapter,
unsortedArraysEqual,
-} from './fields';
+} = fields; // Fix circular dependency issue
export {default as validators} from './validators';
export {default as parsers} from './parsers';
export {default as formatters} from './formatters';It appears to be some circular dependency, or something along those lines, but I can't for the love of god figure out what it is. I ran madge before and after this change and there's no difference, so it might be something else. I'd appreciate some help troubleshooting this. |
0197dca to
016c7ed
Compare
ThiefMaster
left a comment
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.
Works fine! :)
I'll have a look at the weird test failure.
CHANGES.rst
Outdated
| ^^^^^^^^^^^^^ | ||
|
|
||
| - Improve registration form single choice input accessibility (:pr:`6310`, thanks :user:`foxbunny`) | ||
| - Reimplement Checkbox to make it programmatically focusable (:pr:`6528`, thanks :user:`foxbunny`) |
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.
Please rebase and add it to the 3.3.5 section since 3.3.4 has been released last week
indico/modules/events/registration/client/js/form/fields/MultiChoiceInput.jsx
Show resolved
Hide resolved
016c7ed to
9e6100c
Compare
| align-items: center; | ||
| } | ||
|
|
||
| .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.
I had a look in the room booking admin UI where we use quite a few FinalCheckbox components w/ a description below, and the margins seem to be a bit different from other fields. Could you try to align them a bit more with what we have for those other fields? In the screenshot (the page URL is /rooms/admin if you want to go there yourself) it's quite easy to see:
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.
Will check
CHANGES.rst
Outdated
|
|
||
| - Reimplement Checkbox to make it programmatically focusable (:pr:`6528`, thanks :user:`foxbunny`) | ||
|
|
||
| - Nothing so far :( |
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.
that one is meant to be removed when adding the first real changelog line :p
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.
Sorry, didn't notice it.
9e6100c to
414d8f8
Compare
|
Easy fix for the circular import :) (but don't ask me why this fixes it) diff --git a/indico/web/client/js/react/forms/fields.jsx b/indico/web/client/js/react/forms/fields.jsx
index b8ae286405..47cab07161 100644
--- a/indico/web/client/js/react/forms/fields.jsx
+++ b/indico/web/client/js/react/forms/fields.jsx
@@ -12,7 +12,7 @@ import {Field, useFormState} from 'react-final-form';
import {OnChange} from 'react-final-form-listeners';
import {Button, Dropdown, Form, Input, Popup, Radio, TextArea, Icon} from 'semantic-ui-react';
-import {Checkbox} from 'indico/react/components';
+import Checkbox from 'indico/react/components/Checkbox';
import formatters from './formatters';
import parsers from './parsers'; |
Nice. Damn, I thought I'd tried that already. Speaking of those index modules that import bunch of stuff, I noticed that the mincss plugin also doesn't cope so well with them in SCSS. I don't know if we have automatic import ordering in SCSS, but we should, as apparently that helps. |
|
|
||
| import './Checkbox.module.scss'; | ||
|
|
||
| export default function Checkbox({label, onChange, ...inputProps}) { |
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 thing that's currently missing is support for the indeterminate state.
We don't use it with the FinalCheckbox but we have a few places where we use it with "standalone" checkboxes, for "select all/none" on top of tables (in that case the checkboxes typically don't have a visible label btw).
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.
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.
I've added support for the indeterminate state. It is passed in as a Boolean prop, separately from the checked prop, like you would with standard checkboxes. Separately, I've added a showAsToggle prop which makes it look like a toggle button (it's just cosmetics).
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.
Do you want indeterminate state for the toggle button? It's just CSS, I can patch it in if needed.
d921920 to
7d9fc39
Compare
| FormFieldAdapter, | ||
| unsortedArraysEqual, | ||
| } from './fields'; | ||
| } = fields; // Fix circular dependency issue |
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.
I don't think this is still needed w/ the change on how we import the Checkbox component in fields.jsx?
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.
I'll double-check in the morning.
Regarding the icon, replacing that would mean replacing all check marks everywhere. I'm happy to do that tho I find both checkmarks kinda ugly. :)) At least the old one is fatter so easier to spot and doesn't require a colored background to clearly see what's going on. Regarding the color: reason as explained above. The checkmark is too thin. |
What do you mean by that? This PR only changes the SUI checkbox, right? |
It doesn't. My understanding was that we won't vendor SUI and make modifications, so I reimplemented the checkbox. As such it uses the icomoon icon set. |
b718f58 to
629510c
Compare
|
I've changed the background color, but the icon question is still open. To be honest, the whole icon set looks a bit dated and might be better to do a complete rework at some point. Short term we have the following options:
As an FYI, from the accessibility perspective, the icon font as a whole must be replaced with an SVG spritesheet. This is not a high-priority fix as WCAG doesn't even mention it specifically, but it's a real problem for people with dyslexia who use custom fonts to make pages readable. |
|
This is still blocking the error messages PR. Any chance we can get this moving? |
629510c to
7e8193f
Compare
Replace SUI Checkbox with a simpler component so that it can be programmatically focused on error.
7e8193f to
787833c
Compare
| } from 'semantic-ui-react'; | ||
| import {Button, Dropdown, Form, Input, Popup, Radio, TextArea, Icon} from 'semantic-ui-react'; | ||
|
|
||
| import Checkbox from 'indico/react/components/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.
Really weird, when I change this to import Checkbox from 'indico/react/components'; which should be pretty much equivalent since there's a re-report in components, I get this strange error/warning from webpack:
WARNING in chunk common [mini-css-extract-plugin]
Conflicting order. Following module has been added:
* css ../../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].oneOf[2].use[1]!../../../node_modules/resolve-url-loader/index.js??ruleSet[1].rules[2].oneOf[2].use[2]!../../../node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[2].oneOf[2].use[3]!../../../node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].oneOf[2].use[4]!./js/react/components/principals/items.module.scss
despite it was not able to fulfill desired ordering with these modules:
* css ../../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].oneOf[2].use[1]!../../../node_modules/resolve-url-loader/index.js??ruleSet[1].rules[2].oneOf[2].use[2]!../../../node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[2].oneOf[2].use[3]!../../../node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].oneOf[2].use[4]!./js/react/forms/fields.module.scss
- couldn't fulfill desired order of chunk group(s) jquery, exports, module_events.abstracts, module_events.persons, module_events.registration, module_events.sessions, module_events.surveys, module_categories, module_categories.management, module_categories.calendar, module_events.display, module_events.header, module_receipts.admin, module_users.dashboard, module_users.profile_picture, module_users.favorites
- while fulfilling desired order of chunk group(s) main, module_events.contributions, module_events.editing, module_events.management, module_events.papers, module_attachments, module_auth.signup, module_core, module_events.admin, module_events.roles, module_logs, module_rb, module_receipts, module_search, module_users.personal_data, module_users.data_export
(and a few more similar ones)
Do you have any idea which of your changes in this PR may be causing this? Because I have the feeling this may come back to haunt us in the future if some change is introducing an inconsistency w/ CSS ordering...
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.
So while I don't have ideas as to what would cause this or how to find out what causes it, my hypothesis is that we are artificially enforcing an alphabetical order in the components whereas the actual order of (CSS) dependencies is (should be) different. To solve this issue once and for all we have two options:
- Never import CSS in JSX modules
- Never create god modules that import everything
I'm very much in favor of the second option as it also helps improve tree-shaking.
FinalCheckbox was changed to use the new Checkbox component in #6528, but many places still passed `toggle` instead of the new `showAsToggle` via the `FinalCheckbox` component to it. Also changed some places to use the new component (there are more though, but some of them require more style tweaks to not look weird).
FinalCheckbox was changed to use the new Checkbox component in indico#6528, but many places still passed `toggle` instead of the new `showAsToggle` via the `FinalCheckbox` component to it. Also changed some places to use the new component (there are more though, but some of them require more style tweaks to not look weird).
FinalCheckbox was changed to use the new Checkbox component in indico#6528, but many places still passed `toggle` instead of the new `showAsToggle` via the `FinalCheckbox` component to it. Also changed some places to use the new component (there are more though, but some of them require more style tweaks to not look weird).
FinalCheckbox was changed to use the new Checkbox component in indico#6528, but many places still passed `toggle` instead of the new `showAsToggle` via the `FinalCheckbox` component to it. Also changed some places to use the new component (there are more though, but some of them require more style tweaks to not look weird).
FinalCheckbox was changed to use the new Checkbox component in indico#6528, but many places still passed `toggle` instead of the new `showAsToggle` via the `FinalCheckbox` component to it. Also changed some places to use the new component (there are more though, but some of them require more style tweaks to not look weird).





Replace SUI Checkbox with a simpler component so that it can be programmatically focused on error.