Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(core): the tap route reads the shared press slop (#10389)

Christopher Chedeau2d91b990fda5
diff --git a/.changeset/keyboard-tap-route-press-slop.md b/.changeset/keyboard-tap-route-press-slop.md
new file mode 100644
index 0000000000..7cae4e755d
--- /dev/null
+++ b/.changeset/keyboard-tap-route-press-slop.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[chore] Internal: Core's keyboard module reads the press slop that press feedback uses for its tap route, instead of its own copy of the same 10 px, and three source comments that restated names are gone. Apps see no change.
+
+@vjeux
diff --git a/packages/core/src/keyboard/keyboardHeight.ts b/packages/core/src/keyboard/keyboardHeight.ts
index da7fc06b0b..3ae99dc0e2 100644
--- a/packages/core/src/keyboard/keyboardHeight.ts
+++ b/packages/core/src/keyboard/keyboardHeight.ts
@@ -20,6 +20,7 @@ import {armClickGuard} from '../utils/clickGuard';
import {subscribeInput} from '../utils/inputStream';
import {isNode} from '../utils/nodeType';
import {layoutViewportHeight} from '../utils/layoutViewport';
+import {PRESS_SLOP_PX} from '../utils/pressGesture';
import {caretAt} from '../utils/selectionLock';
// A shortfall smaller than this is rounding, not a keyboard.
@@ -540,10 +541,6 @@ export function watchRevealPan(
};
}
-// A touch that moves this far is the browser's to scroll, not a tap on a
-// field. Safari claims a touch for scrolling past 10 px.
-const TAP_SLOP_PX = 10;
-
/** The caller's rules for claimTapFocus. */
export interface ClaimTapFocusOptions {
/** The control a touch on `target` would focus, when this caller claims it. */
@@ -601,7 +598,10 @@ export function claimTapFocus(
start == null ||
event.touches.length !== 1 ||
touch == null ||
- Math.hypot(touch.clientX - start.x, touch.clientY - start.y) > TAP_SLOP_PX
+ // Past the press slop, the touch is the browser's to scroll, not a tap
+ // on a field.
+ Math.hypot(touch.clientX - start.x, touch.clientY - start.y) >
+ PRESS_SLOP_PX
) {
stopFollowing();
}
diff --git a/packages/core/src/keyboard/keyboardTarget.ts b/packages/core/src/keyboard/keyboardTarget.ts
index 8c9014925c..cc92a76bfd 100644
--- a/packages/core/src/keyboard/keyboardTarget.ts
+++ b/packages/core/src/keyboard/keyboardTarget.ts
@@ -120,7 +120,6 @@ export function fixedContainerOf(element: Element): FixedContainer {
return dock === 'docked' ? {docked: node} : dock;
}
-// The nearest fixed-position ancestor of `element`, or null.
function nearestFixedAncestor(element: Element): HTMLElement | null {
const view = element.ownerDocument.defaultView;
if (view == null) {
@@ -184,7 +183,6 @@ function hasOwnTranslate(node: HTMLElement, view: Window): boolean {
return ride == null || ride.get('y') === 0;
}
-// The properties that move a bar on the page.
const POSITION_PROPERTIES = new Set([
'transform',
'translate',
@@ -254,7 +252,6 @@ function isMovedByApp(node: HTMLElement): boolean {
});
}
-// Whether `node` is a fixed container docked to the viewport's bottom edge.
function isDockedContainer(node: HTMLElement): boolean {
const view = node.ownerDocument.defaultView;
return (