Topic: Dynamically changing select options in 4.4.0 is not working if the original select didn't have any options

Espen Rønning priority asked 2 years ago


Expected behavior The first selected option is shown after disposing and recreating a select.

Actual behavior The first selected option is shown twice in the select with two different fonts.

Resources (screenshots, code snippets etc.) https://mdbootstrap.com/snippets/standard/ererling-sande-no/4305186#html-tab-view

If you click the button ("Dispose and recreate select") the new options appear as they should.

If you then remove the option from HTML (so that there is no options in the select) and click the button the first option ("No option selected") is shown twice in the select.

I think this error first occured in 4.4.0, although I've bearly used 4.3.0


Kamila Pieńkowska staff answered 2 years ago


I'm sorry to say this is a bug and we will try to fix this as soon as possible. As a possible workaround, you can set timeout ta add class active. Example snippet: https://mdbootstrap.com/snippets/standard/kpienkowska/4379211


Espen Rønning priority answered 2 years ago


Actually I don't remove options from Html, but initially I don't have any options. For example: When I create the HTML I don't have any options yet. Then (based on other events) I get a list of options and add them to the Select. Then you'll get the result as shown in the snippet when you remove the option from html and run the snippet.

An easy workaround is to always include an option, but that shouln't be necessary (and I don't think its required by the HTML Select spesification).


Kamila Pieńkowska staff answered 2 years ago


Sorry but I don't get what is your problem. Disposing select removes all traces of select except the initial html that was used to initiate it.

But why do you remove options from Html?



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