Feature: add possibility to have disabled options in typeahead dropdown list

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.

1 possible answer(s) on “Feature: add possibility to have disabled options in typeahead dropdown list

  1. @pkozlowski-opensource , Sad to hear that.
    Honestly, I don’t understand why not allow such behavior, even if it doesn’t align with your vision of typeahead – after all it wouldn’t change how typeahead behaves by default (because this would have to be explicitly enabled in configuration) but it will add extensibility point and allow to do what is required in certain particular case.
    I see your point – If typeahead is used only as typeahed – you are right, it doesn’t make sense to show disabled options.
    But often you need to implement some different control similar to existing one (like multiselect in the plunk I posted above with typeahead suggestions list) and in this situation it makes sense to take a existing component (typeahead) as a base and build on it, adding missing functionality. But limitations such as this one (every click closes the dropdown) prevent this extensibility.

    Having that said, I just need to ask one more time before looking for other solutions to my problem (looking for other component library/implementing multiselect from scratch) are you solid on your decision and won’t consider taking a look at PR and seeing if it’s indeed unwanted change?