Commit 14fcd937 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

[directorytree] Ensure activate() is called when a TreeItem is clicked

activate() is inconsistently called when a TreeItem is clicked, but is
always called when the user navigates using the keyboard. Since
activate() is meant to be called when the user activates an item,
regardless of method, ensure this happens.

Bug: 1060061
Change-Id: I3151576f380be6a370962710724c183e1b6f160d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094907Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748578}
parent ad33226a
...@@ -243,6 +243,28 @@ class TreeItem extends cr.ui.TreeItem { ...@@ -243,6 +243,28 @@ class TreeItem extends cr.ui.TreeItem {
* ShortcutItem that don't have children, thus don't need expand icon. * ShortcutItem that don't have children, thus don't need expand icon.
*/ */
updateExpandIcon() {} updateExpandIcon() {}
/**
* Change current directory to the entry of this item.
*/
activate() {}
/**
* Invoked when the tree item is clicked.
*
* @param {Event} e Click event.
* @override
*/
handleClick(e) {
super.handleClick(e);
if (e.button === 2) {
return;
}
if (e.target.classList.contains('expand-icon')) {
return;
}
this.activate();
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -593,14 +615,10 @@ class DirectoryItem extends TreeItem { ...@@ -593,14 +615,10 @@ class DirectoryItem extends TreeItem {
handleClick(e) { handleClick(e) {
super.handleClick(e); super.handleClick(e);
if (!this.entry || e.button === 2) { if (!this.entry) {
return; return;
} }
if (!e.target.classList.contains('expand-icon')) {
this.directoryModel_.activateDirectoryEntry(this.entry);
}
// If this is DriveVolumeItem, the UMA has already been recorded. // If this is DriveVolumeItem, the UMA has already been recorded.
if (!(this instanceof DriveVolumeItem)) { if (!(this instanceof DriveVolumeItem)) {
const location = this.tree.volumeManager.getLocationInfo(this.entry); const location = this.tree.volumeManager.getLocationInfo(this.entry);
...@@ -753,6 +771,7 @@ class DirectoryItem extends TreeItem { ...@@ -753,6 +771,7 @@ class DirectoryItem extends TreeItem {
/** /**
* Change current directory to the entry of this item. * Change current directory to the entry of this item.
* @override
*/ */
activate() { activate() {
if (this.entry) { if (this.entry) {
...@@ -1410,9 +1429,10 @@ class DriveVolumeItem extends VolumeItem { ...@@ -1410,9 +1429,10 @@ class DriveVolumeItem extends VolumeItem {
/** /**
* Change current entry to the entry corresponding to My Drive. * Change current entry to the entry corresponding to My Drive.
* @override
*/ */
activate() { activate() {
VolumeItem.prototype.activate.call(this); super.activate();
this.selectDisplayRoot_(this); this.selectDisplayRoot_(this);
} }
...@@ -1635,7 +1655,6 @@ class ShortcutItem extends TreeItem { ...@@ -1635,7 +1655,6 @@ class ShortcutItem extends TreeItem {
if (e.button === 2) { if (e.button === 2) {
return; return;
} }
this.activate();
// Resets file selection when a volume is clicked. // Resets file selection when a volume is clicked.
this.parentTree_.directoryModel.clearSelection(); this.parentTree_.directoryModel.clearSelection();
...@@ -1666,6 +1685,7 @@ class ShortcutItem extends TreeItem { ...@@ -1666,6 +1685,7 @@ class ShortcutItem extends TreeItem {
/** /**
* Change current entry to the entry corresponding to this shortcut. * Change current entry to the entry corresponding to this shortcut.
* @override
*/ */
activate() { activate() {
const directoryModel = this.parentTree_.directoryModel; const directoryModel = this.parentTree_.directoryModel;
...@@ -1841,7 +1861,7 @@ class FakeItem extends TreeItem { ...@@ -1841,7 +1861,7 @@ class FakeItem extends TreeItem {
* @override * @override
*/ */
handleClick(e) { handleClick(e) {
this.activate(); super.handleClick(e);
DirectoryItemTreeBaseMethods.recordUMASelectedEntry.call( DirectoryItemTreeBaseMethods.recordUMASelectedEntry.call(
this, e, this.rootType_, true); this, e, this.rootType_, true);
...@@ -1858,6 +1878,7 @@ class FakeItem extends TreeItem { ...@@ -1858,6 +1878,7 @@ class FakeItem extends TreeItem {
/** /**
* Executes the command. * Executes the command.
* @override
*/ */
activate() { activate() {
this.parentTree_.directoryModel.activateDirectoryEntry(this.entry); this.parentTree_.directoryModel.activateDirectoryEntry(this.entry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment