fix showing to direct modal in a row

pull/1999/head
yann300 3 years ago
parent 5bb8954296
commit 5c70fdafa0
  1. 1
      libs/remix-ui/app/src/lib/remix-app/interface/index.ts
  2. 4
      libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts
  3. 4
      libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx
  4. 1
      libs/remix-ui/modal-dialog/src/lib/types/index.ts

@ -2,6 +2,7 @@ import { ModalTypes } from '../types'
export interface AppModal { export interface AppModal {
id: string id: string
timestamp?: number
hide?: boolean hide?: boolean
title: string title: string
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef

@ -5,8 +5,10 @@ import { AppModal, ModalState } from '../interface'
export const modalReducer = (state: ModalState = ModalInitialState, action: ModalAction) => { export const modalReducer = (state: ModalState = ModalInitialState, action: ModalAction) => {
switch (action.type) { switch (action.type) {
case modalActionTypes.setModal: { case modalActionTypes.setModal: {
const timestamp = Date.now()
const focusModal: AppModal = { const focusModal: AppModal = {
id: action.payload.id || Date.now().toString(), timestamp,
id: action.payload.id || timestamp.toString(),
hide: false, hide: false,
title: action.payload.title, title: action.payload.title,
message: action.payload.message, message: action.payload.message,

@ -20,9 +20,9 @@ export const ModalDialog = (props: ModalDialogProps) => {
} }
useEffect(() => { useEffect(() => {
calledHideFunctionOnce.current = props.hide calledHideFunctionOnce.current = false
modal.current.focus() modal.current.focus()
}, [props.hide]) }, [props.timestamp])
useEffect(() => { useEffect(() => {
function handleBlur (e) { function handleBlur (e) {

@ -1,6 +1,7 @@
/* eslint-disable no-undef */ /* eslint-disable no-undef */
export interface ModalDialogProps { export interface ModalDialogProps {
id: string id: string
timestamp?: number,
title?: string, title?: string,
message?: string | JSX.Element, message?: string | JSX.Element,
okLabel?: string, okLabel?: string,

Loading…
Cancel
Save