Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda