diff --git a/reflex/.templates/web/utils/state.js b/reflex/.templates/web/utils/state.js index 905c0553773..68c59706f6f 100644 --- a/reflex/.templates/web/utils/state.js +++ b/reflex/.templates/web/utils/state.js @@ -243,13 +243,13 @@ export const applyEvent = async (event, socket) => { if (event.name == "_set_focus") { const ref = event.payload.ref in refs ? refs[event.payload.ref] : event.payload.ref; - const focus = ref?.current?.focus; - if (focus === undefined) { + const current = ref?.current; + if (current === undefined || current?.focus === undefined) { console.error( `No element found for ref ${event.payload.ref} in _set_focus`, ); } else { - focus(); + current.focus(); } return false; }