wagtail icon indicating copy to clipboard operation
wagtail copied to clipboard

Replace `FilterSelectWidget` jQuery with Stimulus `RulesController` uplift

Open lb- opened this issue 4 months ago • 2 comments

[!NOTE]
This PR builds on a previous refactor only PR https://github.com/wagtail/wagtail/pull/13379

This PR completes the third internal admin usage of conditional fields by adding the ability to be used for our FilteredSelect widget, closing https://github.com/wagtail/wagtail/issues/11045 . After this we can start on https://github.com/wagtail/wagtail/issues/2172 if there's a desire to support this 'officially'.

Testing

  • Ensure you have some test data that supports 2-3 workflow different workflow types and then workflow tasks that match to a sub-set of those different types.
  • Navigate to the workflow task report page.
  • In the filter menu option, first check that all tasks are selectable by default.
  • Now change the workflow filter to have a one that should limit the tasks.
  • Observe that the task options should be limited.
  • Select a task type that's only available in one workflow type.
  • Now, go back to the workflow options and select a different workflow type.
  • Observe, the task selection should have been cleared and reset back to default. I.e. it should not keep 'invalid' (filtered) selected values.

Screenshots

When no filtering is active

Workflow select Task (filtered) select
Screenshot 2025-09-01 at 8 14 40 AM Screenshot 2025-09-01 at 8 14 47 AM

When filtering is active

Workflow select Task (filtered) select
Screenshot 2025-09-01 at 8 14 24 AM Screenshot 2025-09-01 at 8 14 30 AM

Changed behaviour to current on Safari

Safari will not honour hidden attributes on option elements, instead we will use hidden & disabled - see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/hidden#browser_compatibility Screenshot 2025-09-01 at 8 34 13 AM

This is a simpler approach, the jQuery approach had to keep a record of the DOM element and re-add it each time. This is error prone and harder to support.

Note that the 'disabled' options are visible but will not be selectable, when/if Safari align with all other browsers and the HTML standard, this will just work as per other browsers in the future.

Safari (before) Safari (after)
Screenshot 2025-09-01 at 8 37 06 AM Screenshot 2025-09-01 at 8 32 59 AM

lb- avatar Aug 31 '25 22:08 lb-

Once 7.2 goes out, I'll have to rebase & fix conflicts on this one.

lb- avatar Nov 05 '25 05:11 lb-

OK - rebased after the 7.2 release & after some changes/rework of https://github.com/wagtail/wagtail/pull/13379

lb- avatar Nov 29 '25 05:11 lb-