Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
How to prevent iOS Safari from making unwanted selections?

When I long-press a toolbar button on my React app in iOS Safari it makes a selection of the icon. I disabled it with CSS on the toolbar:

-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;

But then Safari continues selecting the next silly element it can find.

So in I ended up applying the styles to the root of my app, but now of course the user can't select any text in things like paragraphs.

What I really want is a way to put in a barrier that says "Safari, can you please stop trying to select the next thing you may find?"

So on my toolbar component I do this and I verified it gets called:

  onTouchStart={e => {
    e.stopPropagation();
    e.preventDefault();
    e.bubbles = false;
  }}

I also tried this:

  onTouchStartCapture={e => {
    e.stopPropagation();
    e.preventDefault();
    e.bubbles = false;
  }}

And the same with onSelect, onSelectCapture.

However Safari is ignoring all that and keeps on selecting things up the hierarchy all the way to the root DIV until it finds something nonsensical to select. When I look at what it has selected by copying it, it's just a single whitespace.

What am I missing? Do I really have to apply user-select: none; to the root and then selectively allow selection where it makes sense, such as on DIVs that contain text? And then, how will Safari not find and select that when long-pressing the toolbar?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can apply the following css, so you can still select <p> and <h> tags:

p {
 -webkit-user-select: text !important;
 user-select: text !important;
}
h1 {
 -webkit-user-select: text !important;
 user-select: text !important;
}
h2 {
 -webkit-user-select: text !important;
 user-select: text !important;
}
h3 {
 -webkit-user-select: text !important;
 user-select: text !important;
}
h4 {
 -webkit-user-select: text !important;
 user-select: text !important;
}
h5 {
 -webkit-user-select: text !important;
 user-select: text !important;
}
h6 {
 -webkit-user-select: text !important;
 user-select: text !important;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!