Single on/off option does not work if the filter is not required

Created on 5 January 2016, almost 9 years ago
Updated 9 June 2024, 4 months ago

Followup from #2618500: Single on/off checkbox is always checked β†’ . If the filter is not required, the single on/off option doesn't work as expected. This is because the boolean field is now trinary (yes/no/both).

Suggested fix: only allow the single on/off checkbox option on required boolean fields, but remove the "#required" attribute so that the UX is not complicated by an input-required flag when input is not actually required.

Steps to reproduce:

  1. Navigate to /admin/structure/views/add, View name: on-off test, "Continue & edit"
  2. Edit the existing "Content: Published" filter: tick "Expose this filter...", untick "Required", click "Apply"
  3. Note that the filter operates correctly using Views' select element
  4. Edit "Exposed form style": set to "Better Exposed Filters" and click "Apply"
  5. On the BEF settings page, set the "status" filter display to "Single on/off checkbox" and click "Apply"
  6. Note the same content displays in Views' preview regardless of the "Published" checkbox state
  7. Save the view and navigate to /on-off-test, same content displays regardless of the "Published" checkbox state

Also note, if you set the default value of the filter to "No" it will still render as checked when the page is first loaded. But only if the filter is not required.

πŸ› Bug report
Status

Closed: outdated

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mikeker

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024