Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change onClick to onFocus, with a slight delay for safari #144

Conversation

justcallmelarry
Copy link
Contributor

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

  • Safari 16.5.1
  • Chrome 123.0.6312.86
  • Mobile Safari iOS 17.4.1

Issues

Closes #136 on merge

shynst added a commit to shynst/spliit that referenced this pull request May 28, 2024
@scastiel
Copy link
Member

Thanks @justcallmelarry!

@scastiel scastiel merged commit f9d9153 into spliit-app:main May 30, 2024
1 check passed
@justcallmelarry justcallmelarry deleted the feature/change-select-from-onclick-to-onfocus branch June 5, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow amount cursor edit
2 participants