MCPcopy Create free account
hub / github.com/dailydotdev/apps / focusInputById

Function focusInputById

packages/shared/src/components/post/NewComment.tsx:42–59  ·  view source on GitHub ↗
(inputId: string, remainingFrames = 30)

Source from the content-addressed store, hash-verified

40};
41
42const focusInputById = (inputId: string, remainingFrames = 30): void => {
43 if (typeof document === 'undefined') {
44 return;
45 }
46
47 const input = document.getElementById(inputId);
48 if (input) {
49 input.focus();
50 input.scrollIntoView?.({ behavior: 'smooth', block: 'center' });
51 return;
52 }
53
54 if (remainingFrames <= 0) {
55 return;
56 }
57
58 requestAnimationFrame(() => focusInputById(inputId, remainingFrames - 1));
59};
60
61export interface NewCommentRef {
62 onShowInput: (origin: Origin) => void;

Callers 1

onCommentClickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected