Bug 1846714 Comment 6 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

> Can you provide more specifics about what events are happening where / what code is involved? From your comment, I am struggling to follow what element is receiving a click that didn't before (and why that causes us to open another tab). I cannot reproduce the issue myself on nightly (tested on macOS - only 1 tab opens), so it's hard to know what is going on where.

If you try my attached testcase with STR, you'll see a click event is generated on the `div`, which is not the case before bug 1846754. The explanation is that the `mousedown` happens on the `div`, and the `mouseup` happens on the `button`.  Bug 1846754 updated the common ancestor algorithm, so we start to generate a click event for the `div` now. I guess you don't see it on Mac because these buttons have different DOM tree structures on Mac than Window/Linux. (perhaps the native menus as you said).

> Switching events may be tricky because the click-and-hold stuff is implemented generically in gClickAndHoldListenersOnElement. Does (a variation of) this bug also affect the back/fwd button dropdowns which open the same way?

I tried back/fwd button dropdowns, it seemed fine for me. 

> If the issue is that a click event from the menu item is bubbling up to the button that opened the popup, wouldn't a simpler fix be to call stopPropagation from the click handler on the menuitem, or for the button's handler to ignore events that came from inside its menupopup? Or even to move click handling for the menuitems into the same click handler? I don't really understand what we'd gain by changing the event we use. It's additionally baffling that I can't reproduce on macOS, so clearly something is different there (perhaps the native menus?).

So if you check my updated testcase, you'll see that the menuitem button doesn't get a `click` event and only `mouseup`. So this is why I mentioned switching to `mouseup` earlier. It could be that I don't understand the structure of the `new-tab-button` correctly, and we do get a `click` event for the menuitem items, then I think `stopPropagation()` works. Can you provide me to where we handle the click events for the menuitems, and I can try?
> Can you provide more specifics about what events are happening where / what code is involved? From your comment, I am struggling to follow what element is receiving a click that didn't before (and why that causes us to open another tab). I cannot reproduce the issue myself on nightly (tested on macOS - only 1 tab opens), so it's hard to know what is going on where.

If you try my attached testcase with STR, you'll see a click event is generated on the `div`, which is not the case before Bug 1792110. The explanation is that the `mousedown` happens on the `div`, and the `mouseup` happens on the `button`.  Bug 1792110 updated the common ancestor algorithm, so we start to generate a click event for the `div` now. I guess you don't see it on Mac because these buttons have different DOM tree structures on Mac than Window/Linux. (perhaps the native menus as you said).

> Switching events may be tricky because the click-and-hold stuff is implemented generically in gClickAndHoldListenersOnElement. Does (a variation of) this bug also affect the back/fwd button dropdowns which open the same way?

I tried back/fwd button dropdowns, it seemed fine for me. 

> If the issue is that a click event from the menu item is bubbling up to the button that opened the popup, wouldn't a simpler fix be to call stopPropagation from the click handler on the menuitem, or for the button's handler to ignore events that came from inside its menupopup? Or even to move click handling for the menuitems into the same click handler? I don't really understand what we'd gain by changing the event we use. It's additionally baffling that I can't reproduce on macOS, so clearly something is different there (perhaps the native menus?).

So if you check my updated testcase, you'll see that the menuitem button doesn't get a `click` event and only `mouseup`. So this is why I mentioned switching to `mouseup` earlier. It could be that I don't understand the structure of the `new-tab-button` correctly, and we do get a `click` event for the menuitem items, then I think `stopPropagation()` works. Can you provide me to where we handle the click events for the menuitems, and I can try?

Back to Bug 1846714 Comment 6