Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move 'tab-clicked' message response handling next to 'tab-mouseup' #2306

Merged
merged 4 commits into from
Jun 10, 2019

Conversation

xzn
Copy link
Contributor

@xzn xzn commented Jun 7, 2019

Match behavior described here:

https://github.com/piroor/treestyletab/wiki/API-for-other-addons#when-a-tab-is-clicked

Alternatively there's this workaround for tst-tabflip. Whichever gets merged first...

@piroor
Copy link
Owner

piroor commented Jun 7, 2019

Thanks! Hmm, but you looks don't need to import a background module HandleTabMultiselect from the sidebar, instead you just need to move HandleTabMultiselect.updateSelectionByTabClick to webextensions/sidebar/mouse-event-listener.js. And, there looks to be no reason to keep codes for Constants.kNOTIFY_TAB_MOUSEDOWN at handle-misc.js anymore. Moving those codes to webextensions/sidebar/mouse-event-listener.js together looks to make things more clear.

And one more concern: is this compatible to Multiple Tab Handler and other API clients?

@xzn
Copy link
Contributor Author

xzn commented Jun 7, 2019

Additional changes per request:

Moved Constants.kNOTIFY_TAB_MOUSEDOWN related stuff from handle-misc.js to mouse-event-listener.js.
Moved updateSelectionByTabClick to mouse-event-listener.js, now named updateMultiselectionByTabClick.
Removed Constants.kNOTIFY_TAB_MOUSEDOWN_CANCELED related stuff since it's no longer used.

As for MTH there doesn't seems to be any incompatibility. The API should work just like before except that, if any one of tab-mousedown/tab-mouseup/tab-clicked is cancelled the all related tab operation will be cancelled. Whereas before tab-mouseup was handled separately from tab-mousedown/tab-clicked.

@@ -26,15 +26,10 @@ import * as Background from './background.js';
import * as TabsGroup from './tabs-group.js';
import * as Tree from './tree.js';
import * as Commands from './commands.js';
import * as HandleTabMultiselect from './handle-tab-multiselect.js';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module still need to be loaded from anywhere on the background page (for example background/index.js or background/background.js) to multiselect collapsed tree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry wasn't really understanding how javascript import works. In any case you appear to have already been loading this module in background/index.js. I just tested that multiselect collapsed tree (where collapsed tabs are automatically selected as well) still works.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you right. I missed that it was already loaded from index.js.


(async () => {
log('Constants.kNOTIFY_TAB_MOUSEDOWN');
await Tab.waitUntilTracked(mousedownDetail.tab);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check (L270-L273) looks needless anymore. Originally this was introduced for safety about cross-namespace asynchronous operation, and now the tab (got with const tab = EventUtils.getTabFromEvent(event) || EventUtils.getTabFromTabbarEvent(event);) looks certainly available.

@piroor
Copy link
Owner

piroor commented Jun 10, 2019

Anyway, almost looks good to merge. Thanks a lot!

@piroor piroor merged commit b599b46 into piroor:master Jun 10, 2019
@piroor
Copy link
Owner

piroor commented Jun 10, 2019

After merging I've done some more changes. If my changes break functionalities, please comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants