Generated with the help of an LLM.
Problem/Motivation
I noticed that clicking a row in an entity browser view opened from an Entity Browser Block didn't select it. The browser console shows this error every time the behavior attaches:
Uncaught TypeError: $(...).once is not a function
This comes from js/eb_view_decoration.js, which still calls the jQuery once() plugin. Drupal 10 removed that plugin in favour of core/once. Since the module requires ^10.3 || ^11.0, I think the click-to-select handlers haven't worked on any supported core version. As well, the error fires again on every AJAX response inside the browser, so paging through a view adds a new error each time.
The eb_view_decoration library also doesn't declare any dependencies, so it only works when something else on the page happens to load core/drupal and core/jquery first.
Steps to reproduce
- On Drupal 10.3 or 11, install Entity Browser Block Layout 1.1.0 with an entity browser that uses a view with a table format and the "Entity browser bulk select form" field.
- In Layout Builder, add an Entity Browser Block that uses that browser, and open the browser.
- Click anywhere in a row other than the checkbox. The checkbox doesn't change, and the console shows the error above.
- Page to the next page of results. The error fires again.
Proposed resolution
Switch both handlers to once() from core/once, and add core/drupal, core/jquery and core/once as dependencies of the library.
While I was in there I fixed three smaller things in the same handlers, since they only show up once the clicks actually work:
- A row click now calls
click()on the checkbox instead of flipping itscheckedproperty. Setting the property fires no events, so core's tableselect (the select-all checkbox and its row highlighting) fell out of step with the rows the module selected. - The row handler only matches rows in
tbody. Before, a click in the header row toggled the select-all checkbox without any of tableselect's handling. - Clicks on links, buttons, labels and other form controls inside a row are left alone. The old code only skipped
inputelements.
We could keep the property toggle and trigger change by hand instead. However, clicking the input is shorter and gets both the click and change events that tableselect listens for.
Remaining tasks
User interface changes
Clicking a row in the browser selects it again, which is what the module already intended.
API changes
None.
Data model changes
None.
Issue fork entity_browser_block_layout-3644400
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
deviantintegral commented