mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
web/modal: add error boundary for content
This commit is contained in:
parent
4fc9b88ec6
commit
4074e2ca68
1 changed files with 6 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import React, { Context, JSX, useCallback, useEffect, useLayoutEffect, useReducer, useRef } from "react"
|
import React, { Context, JSX, useCallback, useEffect, useLayoutEffect, useReducer, useRef } from "react"
|
||||||
|
import ErrorBoundary from "../util/ErrorBoundary.tsx"
|
||||||
import { ModalCloseContext, ModalState, openModal } from "./contexts.ts"
|
import { ModalCloseContext, ModalState, openModal } from "./contexts.ts"
|
||||||
|
|
||||||
interface ModalWrapperProps {
|
interface ModalWrapperProps {
|
||||||
|
@ -71,7 +72,11 @@ const ModalWrapper = ({ children, ContextType, historyStateKey }: ModalWrapperPr
|
||||||
}, [historyStateKey, onClickWrapper])
|
}, [historyStateKey, onClickWrapper])
|
||||||
let modal: JSX.Element | null = null
|
let modal: JSX.Element | null = null
|
||||||
if (state) {
|
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) {
|
if (state.boxed) {
|
||||||
content = <div className={`modal-box ${state.boxClass ?? ""}`}>
|
content = <div className={`modal-box ${state.boxClass ?? ""}`}>
|
||||||
<div className={`modal-box-inner ${state.innerBoxClass ?? ""}`}>
|
<div className={`modal-box-inner ${state.innerBoxClass ?? ""}`}>
|
||||||
|
|
Loading…
Add table
Reference in a new issue