prevent ShortcutsModal bouncing offset

This commit is contained in:
Sanster
2022-04-07 21:38:10 +08:00
parent 1812928887
commit c3315a2d2b
3 changed files with 16 additions and 6 deletions

View File

@@ -3,7 +3,8 @@ import React, { ReactNode, useRef } from 'react'
import { useClickAway, useKey } from 'react-use'
import Button from './Button'
interface ModalProps {
export interface ModalProps {
show: boolean
children?: ReactNode
onClose?: () => void
title: string
@@ -11,7 +12,7 @@ interface ModalProps {
}
export default function Modal(props: ModalProps) {
const { children, onClose, className, title } = props
const { show, children, onClose, className, title } = props
const ref = useRef(null)
useClickAway(ref, () => {
@@ -23,7 +24,10 @@ export default function Modal(props: ModalProps) {
})
return (
<div className="modal-mask">
<div
className="modal-mask"
style={{ visibility: show === true ? 'visible' : 'hidden' }}
>
<div ref={ref} className={`modal ${className}`}>
<div className="modal-header">
<h3>{title}</h3>