react-phone-input-2 icon indicating copy to clipboard operation
react-phone-input-2 copied to clipboard

copy and paste phone number didn't work in firefox/macOS

Open shifanpark opened this issue 3 years ago • 1 comments

shifanpark avatar Jul 20 '21 13:07 shifanpark

The problem is with this function https://github.com/bl00mber/react-phone-input-2/blob/master/src/index.js#L644-L649 if you set copy numbers to false then it will work in FF. window.getSelection() does not work in FF on input elements. Fastest fix would to probably just use the search value state variable const text = state.searchValue.replace(/[^0-9]+/g,''); or you could use a querySelector to get the data but since you already have it in state probably not necessary const text = document.querySelector('#inputId').value.replace(/[^0-9]+/g,'');

ckarras11 avatar Oct 22 '21 18:10 ckarras11