astryx icon indicating copy to clipboard operation
astryx copied to clipboard

[Bug] SegmentedControl: in a wrapped layout, a press resolves its option by x only and then clicks the wrong one

Open duytbp opened this issue 2 weeks ago • 3 comments

Description

When SegmentedControl's options wrap onto two rows, a press on an option in the second row resolves its target from the horizontal position only, as if every option sat in one row. About 300 ms later the control clicks that option itself. Pressing "E" in row 2, directly under "B" in row 1, ends with "B" selected.

Expected: the option under the pointer is selected, hit-tested in two dimensions (for example with elementFromPoint), and the control never programmatically clicks a different option.

Also seen: the indicator is measured while the options are momentarily laid out on one row, so in the wrapped layout it sits up to about 115px off.

Reproduction

  1. Render a SegmentedControl with five options, in a 358px container at a 390px viewport width, with CSS that lets the track wrap onto two rows.
  2. Tap the first option of row 2.
  3. After about 300 ms, the option above it in row 1 is selected instead.

Astryx Version

@astryxdesign/[email protected]

Environment

Chromium, touch emulation at 390px width

duytbp avatar Nov 15 '26 10:11 duytbp

Hi, I'd like to take this one.

My plan: fix the press target to hit-test in two dimensions (e.g. elementFromPoint) so a wrapped second-row option resolves to the option under the pointer instead of the one above it, and measure the indicator in the wrapped layout so it doesn't sit ~115px off. I'll add a regression test with five options wrapping in a 358px container.

Does that approach sound right, or is there a preferred direction?

ravindrasinghshah avatar Nov 15 '26 14:11 ravindrasinghshah

(Posted by Cindy's agent.) Thanks @duytbp for the report. A fix is in progress in #12358, which picks the option under the pointer in both directions, so a tap on a wrapped second row selects the right segment. We'll update here when it lands.

cixzhang avatar Nov 19 '26 15:11 cixzhang

(Posted by Cindy's agent.) Thank you, @duytbp! The fix landed in #12358: a tap on a SegmentedControl whose track wraps onto more than one line now selects the segment under your finger. You're credited in the release note, and it ships in the next release. Thanks also to @ravindrasinghshah for offering a plan here.

cixzhang avatar Nov 20 '26 00:11 cixzhang