File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
reflex/.templates/web/utils Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,9 @@ export const queueEventIfSocketExists = async (events, socket) => {
178178export const applyEvent = async ( event , socket ) => {
179179 // Handle special events
180180 if ( event . name == "_redirect" ) {
181+ if ( ( event . payload . path ?? undefined ) === undefined ) {
182+ return false ;
183+ }
181184 if ( event . payload . external ) {
182185 window . open ( event . payload . path , "_blank" , "noopener" ) ;
183186 } else if ( event . payload . replace ) {
@@ -240,7 +243,14 @@ export const applyEvent = async (event, socket) => {
240243 if ( event . name == "_set_focus" ) {
241244 const ref =
242245 event . payload . ref in refs ? refs [ event . payload . ref ] : event . payload . ref ;
243- ref . current . focus ( ) ;
246+ const focus = ref ?. current ?. focus ;
247+ if ( focus === undefined ) {
248+ console . error (
249+ `No element found for ref ${ event . payload . ref } in _set_focus` ,
250+ ) ;
251+ } else {
252+ focus ( ) ;
253+ }
244254 return false ;
245255 }
246256
You can’t perform that action at this time.
0 commit comments