Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Bootstrap 5 Select component not allowing an option with no value to be selected

richard.hetherington priority asked 2 years ago


*Expected behavior*Mark an option as selected on load - set in previous page loadBe able to select an option with no value so that the field can be reset / cleared if no options are valid (optional field)

*Actual behavior*Once an option is marked as selected using attribute, you can no longer select an option with no value. It remains on the same selected value as per page load.

Resources (screenshots, code snippets etc.)https://mdbootstrap.com/snippets/standard/richard-hetherington/4312017


Mateusz Lazaru staff answered 2 years ago


Hi,

check out code in the snippet: https://mdbootstrap.com/snippets/standard/mlazaru/4315990#css-tab-view

const instance = mdb.Select.getInstance(selectEl).setValue('3')


richard.hetherington priority commented 2 years ago

Hi mlazaru, that would require modifying code across many, many websites to put a work around in for something that is standard html.

Why are options with no value not selectable?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 4.2.0
  • Device: Desktop PC
  • Browser: Firefox Developer Edition (latest)
  • OS: Windows 10 Pro
  • Provided sample code: No
  • Provided link: Yes