Skip to content

Commit c810adf

Browse files
committed
fix(core): a coarse pointer that can hover still yields the button's release to its layer
CodeBunny on #8727: - The new hover branch in the button press layer's release arm came after the coarse 'none' arm, and StyleX makes sibling media exclusive with the later winning, so the coarse yield shipped as '(pointer: coarse) and (not (hover: hover))': on a coarse primary pointer that can hover, the button painted the press on itself at full strength while its layer faded. The coarse arm now comes last. - build-css.test.mjs still forbade any hover on a press arm. It now allows it only on the fading arm, in a ':hover' rule under (hover: hover), and checks no coarse 'none' release arm is narrowed to pointers that cannot hover (fails on the previous head).
1 parent e570a85 commit c810adf

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

‎packages/core/src/utils/controlPressLayer.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ export const controlPressLayerStyles = stylex.create({
130130
[PRESSED_ON]: {default: pressedOverlayImage, [COARSE]: 'none'},
131131
// Over the release a hovering pointer's hover paints beneath the
132132
// fading image, so the release lands on it (interactionOverlay).
133+
// The coarse yield comes last: StyleX makes sibling media exclusive,
134+
// the later winning, so a coarse pointer that can hover still yields
135+
// to the layer.
133136
[PRESSED_FADING]: {
134137
default: pressedOverlayImage,
135-
[COARSE]: 'none',
136138
[HOVER_HOVER]: {
137139
default: pressedOverlayImage,
138140
':hover': `${pressedOverlayImage}, ${hoverImage}`,
139141
},
142+
[COARSE]: 'none',
140143
},
141144
},
142145
},

‎scripts/build-css.test.mjs‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,35 @@ describe('build-css astryx.css', () => {
407407
);
408408
expect(paints.length).toBeGreaterThanOrEqual(10);
409409
// Not the hover strength: under a finger there is no hover to land on,
410-
// and a paint that stepped there would still have to step off.
410+
// and a paint that stepped there would still have to step off. Only a
411+
// hovering pointer's own hover paints beneath the fading image: on the
412+
// `fading` arm, in a `:hover` rule under `(hover: hover)`.
411413
const arms = lines().filter(line =>
412414
/\[data-astryx-press="(?:on|fading)"\]/.test(line),
413415
);
414-
expect(arms.some(line => line.includes('--color-overlay-hover'))).toBe(
415-
false,
416+
const hoverArms = arms.filter(line =>
417+
line.includes('--color-overlay-hover'),
416418
);
419+
expect(hoverArms.length).toBeGreaterThan(0);
420+
for (const line of hoverArms) {
421+
expect(line).toContain('[data-astryx-press="fading"]');
422+
expect(line).toContain(':hover');
423+
expect(line).toMatch(/\(hover: ?hover\)/);
424+
expect(line).not.toContain('[data-astryx-press="on"]');
425+
}
426+
// A coarse pointer that can also hover still yields the release to the
427+
// button's compositor layer: its `none` arm is not narrowed to pointers
428+
// that cannot hover.
429+
const coarseYield = arms.filter(
430+
line =>
431+
line.includes('[data-astryx-press="fading"]') &&
432+
/background-image:\s*none/.test(line) &&
433+
/\(pointer: ?coarse\)/.test(line),
434+
);
435+
expect(coarseYield.length).toBeGreaterThan(0);
436+
expect(
437+
coarseYield.filter(line => /not \(hover: ?hover\)/.test(line)),
438+
).toEqual([]);
417439
});
418440
});
419441
describe('the press releases under reduced motion (design:reduced-motion)', () => {

0 commit comments

Comments
 (0)