1
0
Fork 0
forked from Mirrors/gomuks

web/modal: add error boundary for content

This commit is contained in:
Tulir Asokan 2025-02-23 17:58:15 +02:00
parent 4fc9b88ec6
commit 4074e2ca68

View file

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import React, { Context, JSX, useCallback, useEffect, useLayoutEffect, useReducer, useRef } from "react"
import ErrorBoundary from "../util/ErrorBoundary.tsx"
import { ModalCloseContext, ModalState, openModal } from "./contexts.ts"
interface ModalWrapperProps {
@ -71,7 +72,11 @@ const ModalWrapper = ({ children, ContextType, historyStateKey }: ModalWrapperPr
}, [historyStateKey, onClickWrapper])
let modal: JSX.Element | null = null
if (state) {
let content = <ModalCloseContext value={onClickWrapper}>{state.content}</ModalCloseContext>
let content = <ModalCloseContext value={onClickWrapper}>
<ErrorBoundary thing="modal">
{state.content}
</ErrorBoundary>
</ModalCloseContext>
if (state.boxed) {
content = <div className={`modal-box ${state.boxClass ?? ""}`}>
<div className={`modal-box-inner ${state.innerBoxClass ?? ""}`}>