From 0194d1b3eb8fb54ca356acd8757c198223f89f7f Mon Sep 17 00:00:00 2001 From: jamienk Date: Sun, 15 Dec 2013 20:10:47 -0500 Subject: [PATCH] default "space" when not overwriting so autocorrect works on Mobile Safari If no range is selected when the user hits "space" -- and hence is not "overwriting" a selection -- then we should allow the "space" to pass through as default rather than inserting '\u00A0'. Allowing the space to be treated default makes auto-correct continue to work on (at least) iPhones, where the "space" event is what triggers auto-correct, auto-complete, auto-capitalization, 2 spaces marking the end of a sentence, etc. Otherwise, auto-correct breaks. --- src/ice.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ice.js b/src/ice.js index e22be15b..11210d4c 100644 --- a/src/ice.js +++ b/src/ice.js @@ -1512,10 +1512,15 @@ /************************************************************************************/ case 32: - preventDefault = true; var range = this.getCurrentRange(); - this._moveRangeToValidTrackingPos(range, range.startContainer); - this.insert('\u00A0' , range); + if(!range.collapsed) { + preventDefault = true; + this._moveRangeToValidTrackingPos(range, range.startContainer); + this.insert('\u00A0' , range); + } + else { + preventDefault = false; + } break; default: // Ignore key.