I spent literally hours tracing down this issue in my code where ESC was clearing the input text only to find that it wasn't my code doing that. I found that ESC clears the text from <input type="search" />.
So when I found this, I thought all my problems were solved - only removing type="search" removes the button to clear the current text from the input. I figured I could restore this with a quick CSS rule, but it had no effect.
-webkit-appearance: searchfield;
So next I tried preventing the action of ESC on the search field, but was unable to do this with:
evt.preventDefault()evt.stopPropagation()evt.stopImmediatePropagation()-- technically the React equivalentevt.nativeEvent.stopImmediatePropagation()
How can I work around this issue without creating monstrosities in the DOM or in my code reinventing this built-in feature of the browser?