Skip to content

Commit d252ab0

Browse files
refactor: apply full audit report improvements to react-grab (#262)
Co-authored-by: aiden <aiden@million.dev> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 14bc13d commit d252ab0

File tree

5 files changed

+272
-230
lines changed

5 files changed

+272
-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)