Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using onPaste with react-select

I'm trying to get onPaste working with react-select. It seems like, that it is not possible to make use of the event.

Basically I'm just doing this within the <Select/>: onPaste={(e) => this.doPasteMagic(e)}

But it is never fired. Am I missing something or is there another way to distinguish between typing and pasting?

I've seen a few suggestions about using onChange, but this seems dirty to me as well.

like image 829
tschaka1904 Avatar asked Jul 17 '26 20:07

tschaka1904


1 Answers

I was fiddling a lot with that. I find it rather surprising that this is not one of the main features of react-select. Anyway, I've found a workaround for this:

<div style={{height: '100%', width: '100%' }} onPaste={(e) => console.log(e)}>
    <Select .../>
</div>

This seems to do the trick and triggers the right event at the right time.

like image 140
tschaka1904 Avatar answered Jul 20 '26 13:07

tschaka1904