Search code examples
iosionic4

How can I get my Ionic 4 app to long-press select text?


I need for my Ionic 4 app to handle the long-press text select/copy/paste on iOS.

I have tried the following in my global.scss with no success:

* {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important; 
}

and also creating a class that can be included per element:

.selectable {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text; 
}

then

<div class='selectable'>This should be selectable</div>

None of these are working.

Any advice on what I'm doing wrong?


Solution

  • .text-select {
      -webkit-user-select: auto;
    }
    

    then use the class on the specific element you want. sample below

    <ion-text class="text-select">Test</ion-text>