diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 6e6f5656c..75b3cebf1 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -28,6 +28,7 @@ Fixed - URLs are now redacted properly (username/password, and path/query for HTTPS) when using Proxy Autoconfig with QtWebKit - Fixed the web inspector with QtWebEngine - Version checks when starting qutebrowser now also take the Qt version PyQt was compiled against into account +- Hinting a input now doesn't select existing text anymore with QtWebKit v0.10.0 ------- diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py index a5f0e9fe0..9c5840ff7 100644 --- a/qutebrowser/browser/webelem.py +++ b/qutebrowser/browser/webelem.py @@ -326,6 +326,11 @@ class AbstractWebElement(collections.abc.MutableMapping): raise Error("Element position is out of view!") return pos + def _move_text_cursor(self): + """Move cursor to end after clicking.""" + if self.is_text_input() and self.is_editable(): + self._tab.caret.move_to_end_of_document() + def _click_fake_event(self, click_target): """Send a fake click event to the element.""" pos = self._mouse_pos() @@ -356,11 +361,7 @@ class AbstractWebElement(collections.abc.MutableMapping): for evt in events: self._tab.send_event(evt) - def after_click(): - """Move cursor to end after clicking.""" - if self.is_text_input() and self.is_editable(): - self._tab.caret.move_to_end_of_document() - QTimer.singleShot(0, after_click) + QTimer.singleShot(0, self._move_text_cursor) def _click_editable(self, click_target): """Fake a click on an editable input field.""" diff --git a/qutebrowser/browser/webkit/webkitelem.py b/qutebrowser/browser/webkit/webkitelem.py index 259f55e61..f92fe667f 100644 --- a/qutebrowser/browser/webkit/webkitelem.py +++ b/qutebrowser/browser/webkit/webkitelem.py @@ -302,7 +302,9 @@ class WebKitElement(webelem.AbstractWebElement): def _click_editable(self, click_target): ok = self._elem.evaluateJavaScript('this.focus(); true;') - if not ok: + if ok: + self._move_text_cursor() + else: log.webelem.debug("Failed to focus via JS, falling back to event") self._click_fake_event(click_target) diff --git a/tests/end2end/data/hints/input.html b/tests/end2end/data/hints/input.html index b7d86fea8..1e027ab1c 100644 --- a/tests/end2end/data/hints/input.html +++ b/tests/end2end/data/hints/input.html @@ -4,10 +4,21 @@ Simple input + - +
With padding:
+ With existing text (logs to JS):: +
diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature index 68dc9bb1e..d01126958 100644 --- a/tests/end2end/features/hints.feature +++ b/tests/end2end/features/hints.feature @@ -188,6 +188,14 @@ Feature: Using hints And I run :hint Then the error "No elements found." should be shown + @qtwebengine_todo: Doesn't move the cursor to the end + Scenario: Clicking input with existing text + When I set general -> log-javascript-console to info + And I open data/hints/input.html + And I run :click-element id qute-input-existing + And I run :fake-key new + Then the javascript message "contents: existingnew" should be logged + ### iframes @qtwebengine_todo: Hinting in iframes is not implemented yet