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

Unified Diff: chrome/browser/resources/md_history/history_item.js

Issue 2962103002: MD History: Fix text selection in history items (Closed)
Patch Set: Created 3 years, 6 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: chrome/browser/resources/md_history/history_item.js
diff --git a/chrome/browser/resources/md_history/history_item.js b/chrome/browser/resources/md_history/history_item.js
index 646493be7fa3e7b4700951e706ef964ce4eb3638..9aff71fb4c489c1ceebd3a480126fc7ffe5e665a 100644
--- a/chrome/browser/resources/md_history/history_item.js
+++ b/chrome/browser/resources/md_history/history_item.js
@@ -133,6 +133,9 @@ cr.define('md_history', function() {
/** @private {?HistoryFocusRow} */
row_: null,
+ /** @private {boolean} */
+ mouseDown_: false,
+
/** @override */
attached: function() {
Polymer.RenderStatus.afterNextRender(this, function() {
@@ -156,6 +159,12 @@ cr.define('md_history', function() {
* @private
*/
onFocus_: function() {
+ // Don't change the focus while the mouse is down, as it prevents text
+ // selection. Not changing focus here is acceptable because the checkbox
+ // will be focused in onItemClick_() anyway.
+ if (this.mouseDown_)
+ return;
+
if (this.lastFocused)
this.row_.getEquivalentElement(this.lastFocused).focus();
else
@@ -210,6 +219,10 @@ cr.define('md_history', function() {
* @private
*/
onItemMousedown_: function(e) {
+ this.mouseDown_ = true;
+ listenOnce(document, 'mouseup', function() {
+ this.mouseDown_ = false;
+ }.bind(this));
// Prevent shift clicking a checkbox from selecting text.
if (e.shiftKey)
e.preventDefault();
« 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