Fix getComputedStyle running on undefined/null element

This commit is contained in:
Lim Chee Aun 2024-03-02 18:54:27 +08:00
parent d8b0adfe97
commit 8108151fb6

View file

@ -61,6 +61,7 @@ function Modal({ children, onClose, onClick, class: className }) {
const focusElement = const focusElement =
modalRef.current?.querySelector('[tabindex="-1"]'); modalRef.current?.querySelector('[tabindex="-1"]');
const isFocusable = const isFocusable =
!!focusElement &&
getComputedStyle(focusElement)?.pointerEvents !== 'none'; getComputedStyle(focusElement)?.pointerEvents !== 'none';
if (focusElement && isFocusable) { if (focusElement && isFocusable) {
focusElement.focus(); focusElement.focus();