bug: contenteditable not selectable or editable in iOS
See original GitHub issueBug Report
Ionic version:
[x] 4.x
Current behavior:
A <div contenteditable="true">
can’t be edited in iOS mobile view when inside <ion-app>
. Tapping on the div does not make the editor caret appear.
Expected behavior: Be selectable/editable. Can edit contenteditable within ion-app for Android and browser, but not iOS mobile.
Steps to reproduce:
- ionic start ion-app-contenteditable-ios blank --capacitor
- edit app.component.html
<div contenteditable="true" style="height: 100px; background: teal">Editable, outside ion-app</div>
<ion-app style="margin-top: 100px;">
<div contenteditable="true" style="height: 100px; background: tomato">Editable, inside ion-app</div>
</ion-app>
- ionic build
- npx cap add ios
- npx cap open ios
Test in simulator.
Related code: Repo with above example: https://github.com/CFT-Chris/ion-app-contenteditable-ios
Other information: This is the same as #6336 and it still reproduces now. I can confirm adding the CSS is a sufficient workaround:
[contenteditable] {
-webkit-user-select: text;
user-select: text;
}
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.12.0 (C:\Users\Chris\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.4.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Capacitor:
capacitor (Capacitor CLI) : 1.0.0-beta.25
@capacitor/core : 1.0.0-beta.25
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
Why doesn't @contenteditable work on the iPhone?
The design mode and content editable are working fine in IOS 5.But in previous versions it is not working.
Read more >Select all is broken when non-editable block is first/last child of ...
1. Focus contenteditable with non-editable **block** as a first/last child. · 2. Put caret in some editable paragraph next to non-editable block.
Read more >82692 – -webkit-user-select: none makes text fields not editable
I have created this simple test: https://people.igalia.com/clopez/wkbug/82692/test-select-none-input-div-contenteditable.html As far as I ...
Read more >contenteditable - HTML: HyperText Markup Language | MDN
Chrome Edge
contenteditable Full support. ChromeYes. Toggle history Full suppo...
contenteditable="caret". Experimental Full support. ChromeYes. Toggle history Full suppo...
contenteditable="events". Experimental Full support. ChromeYes. Toggle history...
Read more >if your contentEditable does not working, check this out.
Is CSS property -webkit-user-select:none; on the element or its ancestor elements? It prevents the cursor from ever being positioned within the contentEditable ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @peterpeterparker,
I also reproduce what you are seeing (child elements of contenteditables div are immediately blurred trying to select text within them).
Would disabling inputBlurring be too big of a change and impact things outside of contenteditable divs? Perhaps there is a way to disable inputBlurring for contenteditables only?
I’m eyeing this line in particular in inputBlurring:
const SKIP_SELECTOR = 'input, textarea, [no-blur]';
Maybe we could add
[contenteditable]
to that list. I can confirm that if we add theno-blur
attribute to our contenteditable divs the bug you describe no longer reproduces.Also regarding your comment:
I think the
user-select: text
always needs to be applied at the[contenteditable]
level and not theion-app
level, per the proposed PR fix. Otherwise, all contents end up being selectable, which I would assume is the undesired behaviour the originalapp.scss
style was trying to fix given the amount of accidental touch holds, swiping and scrolling on mobile platforms.I’ve cloned and build locally Ionic core and track down the issue in
ion-app
. I figured out that inputShims, which is only imported on iOS, is the root cause of the problem. Commenting the import and the above problem doesn’t happens anymore.Why is another question but that’s a start.
Update: in the script, there is an option inputBlurring which per default is true. turning it to false solves the problem
p.s.: in case of Ionic core, you could disable this blurring function like the following: