Pārlūkot izejas kodu

fix for set_focus not binding this (#5183)

Khaleel Al-Adhami 3 nedēļas atpakaļ
vecāks
revīzija
43c081c793
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  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;
   }