diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-16 16:26:16 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-16 16:26:16 +0200 |
| commit | 17ddd4de9087a98c87bec28a6b773572b1c58b50 (patch) | |
| tree | 8ea8ee7cb57ecd8b0b428b089395c449621c102b /packages/meshbay-hub/tests/test_menu_scroll.py | |
| parent | 2916aa376009283305a7acec4aafa3c96544499e (diff) | |
| download | meshbay-17ddd4de9087a98c87bec28a6b773572b1c58b50.tar.gz | |
menu: do not close on the panel's own scrolling
The dismiss-on-scroll listener is on the capture phase, because `scroll`
does not bubble — so it also heard the menu scrolling itself, and a long
tracklist closed the moment it was wheeled. Filter on the event's origin.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/tests/test_menu_scroll.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_menu_scroll.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_menu_scroll.py b/packages/meshbay-hub/tests/test_menu_scroll.py new file mode 100644 index 0000000..5b680a4 --- /dev/null +++ b/packages/meshbay-hub/tests/test_menu_scroll.py @@ -0,0 +1,76 @@ +""" +A pop-up menu taller than the window can be scrolled without dismissing itself. + +`.ctx-menu` is `overflow-y: auto` under a `max-height`, and a playlist's +tracklist expands *inside* it — sixty tracks is three times the panel's height, +so scrolling is the only way to reach most of them. Both ways of scrolling it +closed it instead: the wheel, and dragging its own scrollbar. Reported against +"remove a track", where the menu vanished before a track could be clicked. + +`scroll` does not bubble, so the listener that dismisses the menu on a page +scroll is on the capture phase — and capture is equally what made it hear the +panel's own scrolling on the way down. + +Measured, not read. `playlist_ui_probe.py` drives the same menu and cannot see +this: it reaches every row with `.click()`, which scrolls nothing at all. + +The last two cases are the ones that must keep closing the menu, and they are +why the fix is a filter on the event's origin rather than a removed listener. +""" + +import json +import shutil +import subprocess +import sys +from pathlib import Path + +import pytest + +HARNESS = Path(__file__).parent / "harness" / "menu_scroll_probe.py" + + +@pytest.fixture(scope="module") +def cases(): + if shutil.which("google-chrome") is None: + pytest.skip("Chrome is not available") + proc = subprocess.run([sys.executable, str(HARNESS)], + capture_output=True, text=True, timeout=90) + data = json.loads(proc.stdout) + assert "error" not in data, f"probe failed: {proc.stdout}{proc.stderr}" + return {c["case"]: c for c in data["cases"]} + + +def test_the_fixture_actually_overflows(cases): + # A menu that fits measures nothing, and would let every assertion below + # pass with the fix removed. + c = cases["the panel is scrollable at all"] + assert c["overflows"], f"60 rows did not overflow the panel: {c}" + + +def test_the_wheel_scrolls_the_menu_instead_of_closing_it(cases): + c = cases["scrolled inside the menu"] + assert c["stillOpen"], "the menu closed when it was scrolled" + assert c["scrollTop"] == 200, "the menu did not scroll" + + +def test_dragging_the_menus_own_scrollbar_does_not_close_it(cases): + c = cases["pressed the menu scrollbar and dragged"] + assert c["stillOpen"], "pressing the scrollbar closed the menu" + assert c["scrollTop"] == 400, "the drag did not scroll" + + +def test_reaching_the_end_does_not_scroll_the_page_behind(cases): + # Chained to the page, that overscroll *is* a page scroll, and a page + # scroll closes the menu on purpose — the same symptom by another door. + assert cases["the panel is scrollable at all"]["overscrollBehaviorY"] == "contain" + + +def test_a_press_outside_still_closes_it(cases): + assert cases["pressed outside the menu"]["closed"] + + +def test_scrolling_the_page_still_closes_it(cases): + # Not optional: the menu is `position: fixed` and the media grids scroll + # under a sticky toolbar, so a menu that survives leaves itself pointing at + # an album that has moved. + assert cases["scrolled the page underneath"]["closed"] |