Repository navigation
Make the menu usable on touch devices in landscape - #446
Merged
Merged
Conversation
On a phone held sideways the layout fell back to the desktop menu bar, where the dropdowns have nowhere to go: long menus ran off the bottom of the screen without scrolling (pfalstad#430) and nested submenus opened to the right, past the edge of the viewport, where they could not be reached (pfalstad#431). The same code works in portrait, where the collapsed (hamburger) layout is used. * Apply the collapsed layout to (pointer: coarse) as well, so touch devices get the same menu in both orientations. (pointer: coarse) is the primary input, so a laptop with a touchscreen and a mouse still gets the desktop bar. * Replace the bare burger glyph with a labelled, coloured "Menu" button at the top left (it shows a close mark while the menu is open). The component search field sits at the right end of the menu bar with a higher z-index and had covered the icon completely, leaving the menu unreachable; the field shifts right where the button needs the room. * Start touch devices without the 40px icon toolbar: the menu reaches the same commands and the canvas gains the height (Options > Toolbar brings it back). * Expand nested submenus inline (accordion), indented per level, instead of sideways; never scroll the panel while opening one: the entry moved out from under the finger and the next tap ran the first child command, silently adding an element. * Open submenus on tap, not on touchstart (a swipe opened whatever was under the finger), and only on hover for a real mouse -- a touch tap fires a synthesized mouseover, which shifted the entries and made the following click miss. In the collapsed layout hover opens nothing at all: that layout is a list for tapping, and it is used by narrow windows as well, where hovering popped menus open. * Decide dismissal in one place (dismissesMenus): an interaction inside a panel never closes the menus, and a tap within 16px of an open panel counts as aiming at it. That replaces the per-element stopPropagation calls, which never covered panels built elsewhere, separators or gaps, and it fixes taps beside the panel, at the submenu arrow or on the bar just above it, which used to close everything ("the menu closes by itself"). * Size the sidebar in the touch layout from the width its contents are laid out for (128..166px) instead of a hardcoded 128px, which clipped the sliders and labels on a wider screen in landscape. * Give the sidebar sliders touch-action: pan-y and only take horizontal drags, so a finger that lands on a slider to scroll the panel scrolls it instead of moving the slider. * Keep context menus inside the viewport and let them scroll when they are taller than the room below the touch point. Fixes pfalstad#430 Fixes pfalstad#431
Picking a tool in the collapsed (touch) layout left the hamburger menu list and the sidebar covering the canvas, so there was no visible place to drop the element. setMouseMode(MODE_ADD_ELM) -- the one path every menu, submenu, shortcut and toolbar selection goes through -- now closes the dropdowns and unchecks both overlay triggers. UI tests: touch layout (menus closed, element still placeable) and desktop (sidebar untouched).
Owner
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The menu bar fell back to the desktop layout whenever the window was wider than 600px,
so on a phone held sideways the dropdowns had nowhere to go: long menus ran off the
bottom of the screen without scrolling (#430) and nested submenus opened to the right,
past the edge of the viewport, where they could not be reached (#431). Portrait worked,
because that is where the collapsed (hamburger) layout was used.
Two commits:
Make the menu usable on touch devices in landscape
(pointer: coarse)as well, so touch devices getthe same menu in both orientations.
(pointer: coarse)is the primary input, so alaptop with a touchscreen and a mouse still gets the desktop bar.
close mark while the menu is open). The component search field, which sits at the
right end of the bar with a higher z-index, had covered the icon completely.
and the canvas gains the height (
Options > Toolbarbrings it back).and opening one never scrolls the panel — the entry used to move out from under the
finger and the next tap ran the first child command, silently adding an element.
touchstart(a swipe opened whatever was underthe finger), and only on hover for a real mouse: a touch tap fires a synthesized
mouseover, which shifted the entries so the following click missed. In the collapsedlayout hover opens nothing at all.
dismissesMenus): an interaction inside a panelnever closes the menus, and a tap within 16px of an open panel counts as aiming at it.
This replaces the per-element
stopPropagationcalls, which never covered panelsbuilt elsewhere, separators or gaps.
of a hardcoded 128px, which clipped the sliders and labels in landscape.
touch-action: pan-yand only take horizontal drags, so a fingerthat lands on one to scroll the panel scrolls it instead of moving the slider.
below the touch point.
Close the menus and the sidebar once an element is picked
Picking an element left the hamburger menu list — and the sidebar, if it was open —
covering the canvas, so there was no visible spot to drop it: the first tap on the canvas
both dismissed the overlay and placed the element there, which is not where the user
aimed. Every way of picking a tool (menu item, submenu item, keyboard shortcut, toolbar
variant popup) ends in
UIManager.setMouseMode(MODE_ADD_ELM), which now calls a newcloseMenusAndOverlays()ints/Menus.ts: it closes the dropdowns as before and alsounchecks the two overlay triggers,
#toptrigger(menu list) and#trigger(sidebar).The desktop layout is untouched — those checkbox rules only exist inside the
(max-width: 600px), (pointer: coarse)media query, and there the sidebar keeps itsinline width.
A build with both commits running: https://circuit-demo.behrends.xyz/ — on a touch
screen, open the menu (or the sidebar), pick a component from
Draw, and the canvas isfree to place it.
Tests: two new UI tests in
ts/ui-tests/menus.spec.ts(touch layout: sidebar and menuclosed after picking, and the element still drags out normally; desktop: the sidebar
keeps its width — both fail without the change).
tsc --noEmitandnpm test(vitest,185 tests) pass. In
npm run test:ui,menus,polarcapandeditingpass;build-fullrectandbuild-td4fail on this machine with and without the change.Fixes #430
Fixes #431