Reputation: 56968
I've got an <input>
that onFocus is selecting the text:
onFocusHandler = (event) => {
event.currentTarget.select()
}
This works fine in Chrome, but when I view it in "Device" mode, each time the text is selected, the context menu shows up with "Look up <selected text>" at the top. Is there a different way to select the text that won't do this?
Upvotes: 3
Views: 221
Reputation: 56968
Based on Сергей Петрашко's comment, I gave this a shot:
<Input
type="number"
value={value || ''}
onChange={this.onChangeHandler}
onFocus={this.onFocusHandler}
onContextMenu={e => e.preventDefault()}
onUnfocusHandler={this.onUnfocusHandler}
/>
This prevents the context menu from showing. I also found that just using onClick
to select the text does not show the context menu either (without preventing the onContextMenu
event).
Upvotes: 3