Topic: Unable to select empty value option from select when another option is preselected.

Espen Rønning priority asked 1 year ago


Expected behavior I have a select where one option value is blank and another option is preselected. When I click on the blank option it should be selected.

Actual behavior When I click on the blank option the select box shows the preselected option

Resources (screenshots, code snippets etc.) In this snippet I have two selects. One MDB-select and one plain HTML. Try selecting "No value" and see the difference. https://mdbootstrap.com/snippets/standard/ererling-sande-no/5055156


richard.hetherington priority commented 1 year ago

Hi Espen Rønning, I have asked this question a few times also and provided the same example code. Situation gets worse if you mark an option as selected via selected attribute.

I have found 2 options help.

1/. Add a dummy value to the empty value option e.g. ALL -1 9999999 etc and if you detect this sever-side, ignore it.

2/. Add data-mdb-clear-button="true" to select and allow user to click on the x to remove value. I have not as yet been able to find a way to programatically click on the x from code.

I think they need to correct this odd behaviour of not allowing empty value oiptions to be selected. If using selects to filter datatable having empty values is a way of resetting datatable filtering as one example.

Richard Hetherington


Mateusz Lazaru staff answered 1 year ago


Thank you for reporting this. We are already aware of this error. There is one possible workaround for that:

https://mdbootstrap.com/snippets/standard/mlazaru/5082121

I must say it's not a perfect solution, and it may not work in other cases, but in this one it should do the job. We will fix the issue soon.



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 6.1.0
  • Device: PC
  • Browser: Google Chrome
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: Yes