Browse Source

Backport PR #12496: Handled new dialog creation with no buttons (#12525)

Co-authored-by: John Nnamchi <john.nnamchi@mail.mcgill.ca>
MeeseeksMachine 3 years ago
parent
commit
1f3086f072
1 changed files with 2 additions and 2 deletions
  1. 2 2
      packages/apputils/src/dialog.tsx

+ 2 - 2
packages/apputils/src/dialog.tsx

@@ -245,7 +245,7 @@ export class Dialog<T> extends Widget {
         this._primary = el as HTMLElement;
       }
     }
-    this._primary.focus();
+    this._primary?.focus();
   }
 
   /**
@@ -388,7 +388,7 @@ export class Dialog<T> extends Widget {
     const target = event.target as HTMLElement;
     if (!this.node.contains(target as HTMLElement)) {
       event.stopPropagation();
-      this._buttonNodes[this._defaultButton].focus();
+      this._buttonNodes[this._defaultButton]?.focus();
     }
   }