-
Notifications
You must be signed in to change notification settings - Fork 35
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
Rewrite LiveSearch as an ES Module #5370
base: main
Are you sure you want to change the base?
Conversation
ed0bb95
to
b2bd12f
Compare
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.
This looks good to me. I spotted a few things, one a bit pedantic and the other more of a question. Everything else great though 👍🏻
4b165ad
to
c036ea6
Compare
spotted an issue with template search :( |
c036ea6
to
8966f33
Compare
rename and adapt to ES Module
We want to migrate all of our legacy Javascript files to ESM, so this is the latest in the series of conversions. Rewrite follows the same conventions we previously used for FocusBanner, Collapsible checkboxes, ColourPreview, FileUpload, Autofocus, PreviewPane and CopyToClipboard. Added bonus: removes the use of jQuery as well
We use hidden attribute to hide items that don't match live-search results. Normally, the broser would hide the element, but as these ones have the display property set, we need to set additional override styles.
There are some items that are hidden by default with CSS and which we need to show if they match the search query. Whiel we do the visibility toggling by applying the `hidden` attribute to the each item, we cannot use the same attribute of the hiden-by-default items, as the checkbox macro from DS does not accomodate for that, hence they're hidden by css class. This adds a bit more logic to the JS to apply a new class to those items when they match the search query and use CSS to show them, as well as remove the same class when they don't match or the search query is empty (default state)
When they match the search query
8966f33
to
3d45002
Compare
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 for the late re-review, all looking good now 👍🏻
We want to migrate all of our legacy Javascript files to ESM, so this is the latest in the series
of conversions.
Rewrite follows the same conventions we previously used for FocusBanner, Collapsible checkboxes,
ColourPreview, FileUpload, Autofocus, PreviewPane and CopyToClipboard.
Added bonus: removes the use of jQuery.
In this PR we:
How to test