blueprint icon indicating copy to clipboard operation
blueprint copied to clipboard

Omnibar doesn't close when escape is pressed

Open jkillian opened this issue 6 years ago • 1 comments

Environment

  • Package version(s): select 3.0.0

Steps to reproduce

  • open the omnibar example in the docs
  • type something to see some results
  • press esc

Actual behavior

  • omnibar stays open

Expected behavior

  • omnibar closes

Possible solution

This was caused by removing the onBlur handler in https://github.com/palantir/blueprint/pull/2645. I believe users may be able to work around this issue by adding a keypress listener to the omnibar input and listening for the escape key, but I haven't tested. Either way though, it feels like this should be handled by default by the component? Or at the very least the example should handle this so users know what to do.

jkillian avatar Jul 17 '18 18:07 jkillian

Actually, I don't think this works:

    // omnibar prop
    inputProps={{onKeyDown: this.handleKeyDown}}

    private handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
        if (e.which === Keys.ESC) {
            this.handleClose();
        }
    }

When I tried the above, all keys except the escape key triggered handleKeyDown, but the escape key is getting intercepted somewhere before then.

jkillian avatar Jul 17 '18 20:07 jkillian

I noticed https://github.com/palantir/blueprint/issues/6873 while looking at this but this issue does not reproduce anymore

evansjohnson avatar Jun 26 '24 13:06 evansjohnson