浏览代码

fix for set_focus not binding this (#5183)

Khaleel Al-Adhami 2 周之前
父节点
当前提交
43c081c793
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      reflex/.templates/web/utils/state.js

+ 3 - 3
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;
   }