Skip to content

Add ability to disable specific elements in a ComboBox - #261

Open
dylan-poole wants to merge 4 commits into
josefarias:mainfrom
dylan-poole:dpoole/feat-add-disable-to-options
Open

Add ability to disable specific elements in a ComboBox#261
dylan-poole wants to merge 4 commits into
josefarias:mainfrom
dylan-poole:dpoole/feat-add-disable-to-options

Conversation

@dylan-poole

Copy link
Copy Markdown

What changed:

  • feat: Allow users to add the attribute disabled to Listbox::Options.
  • feat: Added CSS for disabled options in the listbox.
  • feat: add options collection for list boxes that displays disabled options but excludes them from selection.
  • test: Added a disabled options combobox_tag to the disabled.html.erb view.

Additional Information

  • We decided it was best to only support disabled options when passing a hash to combobox_tag.
  • This can be further expanded if we would like to look into creating a helper function for combobox_options, like options_for_select.
  • This PR resolves discussion 126.

Testing Instructions

  1. Run the dummy app and navigate to: /disabled.
  2. Click on the ComboBox labeled, State (with disabled options).
  3. Expect all states that start with the letter 'A' to be disabled.
  4. Ensure you cannot select them and that you cannot navigate to them.
  5. Ensure you cannot get to any disabled elements by using the Home or End key press.
  6. Ensure you cannot get to any disabled elements by using the search feature.

@dylan-poole
dylan-poole marked this pull request as ready for review July 13, 2025 00:23
@dylan-poole

Copy link
Copy Markdown
Author

@josefarias As promised, sorry for the delay I kept running into to other ways you could select a disabled element! Let me know if there are any areas that need to be tweaked, it was great meeting with you at RailsConf!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant