javascript-tutorial / javascript-tutorial/en.javascript.info

Text selection is reset after pressing a button in iOS/iPadOS

Open
#3,087 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
25.5k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Problem
The Selection and Range article includes a demo button that should show an alert with the selected text. On desktop environments or non-Apple mobile devices, the demo works correctly. The alert shows the current selected text, while the selection itself is also maintained.

However on iOS/iPadOS devices(iPhone, iPad, ...) the text selection disappears as soon as you press the button and the alert appears with empty text.

I believe this is an issue with iOS/iPadOS Safari, rather than a bug in javascript.info but nevertheless I wonder if anyone could share some insight on why this isn't working as expected. I've tried my best but up to this point could not find any similar troubleshooting anywhere else.

https://user-images.githubusercontent.com/34783801/176479597-5d7d5621-a513-497a-a114-3cd4b2c055f8.MP4

.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Selection and Range article and its demo button, then reproduce the behavior on iOS/iPadOS Safari using the supplied example. Compare the selected text and alert behavior with desktop and non-Apple mobile environments; done means establishing whether this is a Safari limitation or an issue in the demo and recording the evidence or a supported workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.