I want to be able to mark some items in typeahead dropdown list as
disabled, based on some custom logic.
In fact this much is already possible – I can mark options as disabled and style them to look different from normal options, but I also want them to behave as you would expect disabled option to behave, which is don’t react when user clicks on it or tries to select it via keyboard.
I can easily check if user selected disabled value and ignore such value, but the problem is, and this is deal-breaker, I need the dropdown to stay open when click on disabled option happens. And this is the problem. See, Typeahead component closes options popup window whenever user clicks on any option. So, we could add a quick check to see if the option that user tries to select is disabled and don’t close the dropdown in this case.
So, what I’m thinking is we could add an option to the config which enables this behavior. If typeahead was configured with this feature turned on, typeahead will just ignore select events on an option that has
disabled: true flag.
This isn’t hard to implement, I already checked and it works seamlessly, so if you guys don’t mind I’d be happy to make a PR.
Here’s a plunk to illustrate one possible use case for that.