DEV: Fix select-kit deprecations (PR #15080)

GitHub

@jjaffeux I added a change in DEV: Fix select-kit deprecations by CvX · Pull Request #15080 · discourse/discourse · GitHub since it turns out we had disabled and isDisabled options simultaneously, and they did different things :eyes: I guess we should support only options.disabled. My question though: is that early return in select-kit-header still required though or should I remove it instead using options.disabled there?

@jjaffeux I added a change in 4238953 since it turns out we had disabled and isDisabled options simultaneously, and they did different things :eyes: I guess we should support only options.disabled. My question though: is that early return in select-kit-header still required though or should I remove it instead using options.disabled there?

Yes I think we need to do this:

  • remove isDisabled
  • uses selectKit.options.disabled as early return in header file, however we should slightly improve it:
    if (this.selectKit.options.disabled) {
      if (event.key !== "Tab") {
        event.preventDefault();
      }
      
      return;
    }

This way we keep it focusable but ensure nothing but tab happens on it. Might be an easier solution but that seems quite ok AFAICT right now.

  • you will need to add disabled: false in the selectKitOptions object of select-kit.js file

I can do it in a different PR if you prefer too, up to you, I might want to write a test for this disabled behavior.