I have a div with contenteditable="true"
. I can enter text into the div
with IE, Chrome and Firefox but not Safari. I finally tracked the problem down to the style declarations below given to the container of the div.
container {
-webkit-user-select : none;
-moz-user-select : none;
-khtml-user-select : none;
-ms-user-select : none;
}
I put these in a while ago per Chrome taking first double-click to keep the container from turning blue when it was double-clicked. Now I'm just finding out that that solution breaks Safari contenteditable
.
Does anyone know exactly what these things are doing and why they break Safari contenteditable
?
user-select
This property controls the actual Selection operation0. This is useful in situations where you want to provide an easier/cleaner copy-paste experience for users (not have them accidentally text-select useless things, like icons or images).1
Example of how the property works: http://jsfiddle.net/chriscoyier/vGG8F/3/
Since Safari is built on webkit -webkit-user-select : none;
is the culprit. Removing that will allow the contenteditable
to work again. However, you need that due to your original problem.
Others have run into the same problem which may provide a solution.
You could also catch the double click as suggested in your first question and then disable the -webkit-user-select
allowing the div
to be editable. Once the editing is complete -webkit-user-select
could be set back to none
.
0https://developer.mozilla.org/en-US/docs/Web/CSS/user-select
1http://css-tricks.com/almanac/properties/u/user-select/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With