blueprint
blueprint copied to clipboard
Omnibar doesn't close when escape is pressed
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.
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.
I noticed https://github.com/palantir/blueprint/issues/6873 while looking at this but this issue does not reproduce anymore