change onClick to onFocus, with a slight delay for safari #144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
I originally wanted to make the amount field select
onFocus
, as I wanted it to be possible to choose parts of the amount.It was then pointed out that
onFocus
does not work for Safari, since the way onMouseUp works there deselects the text again after initially selecting it.Therefore the choice was made to go with
onClick
instead, which seemed to work out for everyone involved, and you could still move around using the arrow keys for example if you just wanted to do edits.Along came #136!
So I decided to look into getting it to work better, and more in line with the original thought.
Solution
After scouring the net I found that there is a rather simple solution for allowing this to work on Safari as well, which is to add a small delay to the selection of the input, since then the
mouseup
event will have come and gone.I'm not sure if there are other concerns regarding the solution, but I am open to feedback on it.
Tested on
Issues
Closes #136 on merge