Skip to content

Commit c8f79a9

Browse files
refactor: apply full audit report improvements
- 2a: Convert copyFeedbackCooldown from this-based object to closure-based pattern - 2b: Rename holdState → activationHoldState for clarity - 2c: Rename detectionState → elementDetectionState for clarity - 3a: Extract toPageCoordinates helper to deduplicate page-coordinate calculation - 3b: Extract getElementBoundsCenter utility to utils/ - 3c: Extract updateToolbarState helper to eliminate duplicate toolbar state reconstruction - 4c: Inline start method in createAutoScroller (was trivial wrapper) - 4d: Extract recomputeLabelInstance function for readability - 5a: Extract handleCopySuccessWithComments from deeply nested callback - 5b: Extract getNearestEdge to utils/get-nearest-edge.ts - 5d: Remove unnecessary 'as' casts in selection-label/index.tsx Co-authored-by: aiden <aiden@million.dev>
1 parent 14bc13d commit c8f79a9

File tree

5 files changed

+269
-230
lines changed

5 files changed

+269
-230
lines changed

packages/react-grab/src/components/selection-label/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ export const SelectionLabel: Component<SelectionLabelProps> = (props) => {
179179
const currentElementIdentity = elementIdentity();
180180
const didReset =
181181
currentElementIdentity !== previousResult.elementIdentity;
182-
const cached = didReset
182+
const cached: PositionResult = didReset
183183
? {
184184
position: DEFAULT_OFFSCREEN_POSITION,
185-
computedArrowPosition: null as ArrowPosition | null,
185+
computedArrowPosition: null,
186186
hadValidBounds: false,
187187
elementIdentity: currentElementIdentity,
188188
}
@@ -298,10 +298,10 @@ export const SelectionLabel: Component<SelectionLabelProps> = (props) => {
298298
},
299299
{
300300
position: DEFAULT_OFFSCREEN_POSITION,
301-
computedArrowPosition: null as ArrowPosition | null,
301+
computedArrowPosition: null,
302302
hadValidBounds: false,
303303
elementIdentity: "",
304-
},
304+
} satisfies PositionResult,
305305
);
306306

307307
const arrowPosition = () =>

packages/react-grab/src/core/auto-scroll.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export const createAutoScroller = (
6565
}
6666
};
6767

68-
const start = () => {
69-
scroll();
70-
};
71-
7268
const stop = () => {
7369
if (animationId !== null) {
7470
nativeCancelAnimationFrame(animationId);
@@ -79,7 +75,7 @@ export const createAutoScroller = (
7975
const isActive = () => animationId !== null;
8076

8177
return {
82-
start,
78+
start: scroll,
8379
stop,
8480
isActive,
8581
};

0 commit comments

Comments
 (0)