Skip to content

Commit 753293c

Browse files
committed
Fix hoverOnly type compatibility with controller
Implement hoverOnly check at React layer and pass only scrollToNearestTarget to the controller, fixing TypeScript error.
1 parent 6600000 commit 753293c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/useContentLink/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,20 @@ export function useContentLink(
144144

145145
// Stable method references that call through to the controller
146146
const enableClickToEdit = useCallback((opts?: ClickToEditOptions) => {
147-
controllerRef.current?.enableClickToEdit(opts);
147+
// If hoverOnly is true, check if the device supports hover
148+
if (opts?.hoverOnly) {
149+
const supportsHover =
150+
typeof window !== 'undefined' &&
151+
window.matchMedia('(hover: hover)').matches;
152+
if (!supportsHover) {
153+
// Don't enable click-to-edit on touch-only devices
154+
return;
155+
}
156+
}
157+
158+
controllerRef.current?.enableClickToEdit(
159+
opts?.scrollToNearestTarget ? { scrollToNearestTarget: true } : undefined,
160+
);
148161
}, []);
149162

150163
const disableClickToEdit = useCallback(() => {

0 commit comments

Comments
 (0)