Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2512)

Unified Diff: appengine/chromium_rietveld/new_static/components/cr-user-autocomplete.html

Issue 2208573003: Fix cr-user-autocomplete for Chrome. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Use String#contains Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/chromium_rietveld/new_static/components/cr-user-autocomplete.html
diff --git a/appengine/chromium_rietveld/new_static/components/cr-user-autocomplete.html b/appengine/chromium_rietveld/new_static/components/cr-user-autocomplete.html
index 7140c5791c062e5610bd0fa20d535b93064053a6..c4853fd107993525a1ea75e372055ad76a8d49e5 100644
--- a/appengine/chromium_rietveld/new_static/components/cr-user-autocomplete.html
+++ b/appengine/chromium_rietveld/new_static/components/cr-user-autocomplete.html
@@ -150,21 +150,26 @@ found in the LICENSE file. -->
input.selectionStart = range.end;
input.selectionEnd = input.selectionStart;
- // For Safari/Chrome:
- // Simulate the user entering the text. This makes undo work properly instead of using
- // data binding which is like a big "replace" action.
- var inputEvent = document.createEvent("TextEvent");
- if (inputEvent.initTextEvent) {
- inputEvent.initTextEvent("textInput", true, true, window, value, 0, "en-US");
- input.dispatchEvent(inputEvent);
- } else if (window.InputEvent) {
- // For Firefox we can just update the value and undo will work.
+ // Make sure the input is focused.
+ input.focus();
+
+ // TODO(esprehn): This is a terrible hack but there's no obvious
+ // work around since execCommand doesn't work for input in Firefox
+ // and I can't figure out how to detect that, and we shouldn't
+ // feature detect based on InputEvent otherwise it'll break Chrome
+ // later.
+ if (navigator.userAgent.contains("Firefox")) {
PhistucK 2016/08/03 15:51:20 Yes, no. :P
+ // For Firefox we can just update the value and undo will work,
+ // execCommand doesn't seem to update the input value.
input.value = input.value.to(input.selectionEnd) + value + input.value.from(input.selectionEnd);
input.dispatchEvent(wrap(new InputEvent("input", {
data: value,
bubbles: true,
cancelable:false
})));
PhistucK 2016/08/03 15:51:20 Perhaps this is a Blink issue. Have you filed one?
+ } else {
+ // Chrome and Safari can use execCommand.
Bons 2016/08/03 15:49:42 FYI Polymer Rietveld doesn’t render in Safari (mob
esprehn 2016/08/03 16:46:53 It works for me in WebKit nightly , where do you s
+ document.execCommand("InsertText", false, value);
PhistucK 2016/08/03 15:51:20 Yes, well, this is non-standard. I advise against
esprehn 2016/08/03 16:46:53 Given that there's no workaround we're going to do
}
// Put the caret back at the end of the new input. This also makes sure the input scrolls
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698