Skip to content

Commit

Permalink
DevTools: Delay TabbedPane dropdown from showing on mousedown
Browse files Browse the repository at this point in the history
This matches the behavior we have in UI.ToolbarMenuButton

Bug: 830320
Change-Id: Icb8692cebda088acdfb87abe391f033ffd2bd168
Reviewed-on: https://chromium-review.googlesource.com/1014632
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554196}
  • Loading branch information
JoelEinbinder authored and Commit Bot committed Apr 26, 2018
1 parent edfd09d commit b95be12
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions third_party/blink/renderer/devtools/front_end/ui/TabbedPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ UI.TabbedPane = class extends UI.VBox {
this._currentTabLocked = false;
this._autoSelectFirstItemOnShow = true;

this._triggerDropDownTimeout = null;
this._dropDownButton = this._createDropDownButton();
UI.zoomManager.addEventListener(UI.ZoomManager.Events.ZoomChanged, this._zoomChanged, this);
this.makeTabSlider();
Expand Down Expand Up @@ -560,17 +561,25 @@ UI.TabbedPane = class extends UI.VBox {
const dropDownContainer = createElementWithClass('div', 'tabbed-pane-header-tabs-drop-down-container');
const chevronIcon = UI.Icon.create('largeicon-chevron', 'chevron-icon');
dropDownContainer.appendChild(chevronIcon);
dropDownContainer.addEventListener('click', this._onDropDownMouseDown.bind(this));
dropDownContainer.addEventListener('mousedown', this._onDropDownMouseDown.bind(this));
dropDownContainer.addEventListener('click', this._dropDownClicked.bind(this));
dropDownContainer.addEventListener('mousedown', event => {
if (event.which !== 1 || this._triggerDropDownTimeout)
return;
this._triggerDropDownTimeout = setTimeout(this._dropDownClicked.bind(this, event), 200);
});
return dropDownContainer;
}

/**
* @param {!Event} event
*/
_onDropDownMouseDown(event) {
_dropDownClicked(event) {
if (event.which !== 1)
return;
if (this._triggerDropDownTimeout) {
clearTimeout(this._triggerDropDownTimeout);
this._triggerDropDownTimeout = null;
}
const rect = this._dropDownButton.getBoundingClientRect();
const menu = new UI.ContextMenu(event, false, rect.left, rect.bottom);
for (let i = 0; i < this._tabs.length; ++i) {
Expand Down

0 comments on commit b95be12

Please sign in to comment.