Skip to content

Commit 5c70fda

Browse files
committed
fix showing to direct modal in a row
1 parent 5bb8954 commit 5c70fda

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

libs/remix-ui/app/src/lib/remix-app/interface/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ModalTypes } from '../types'
22

33
export interface AppModal {
44
id: string
5+
timestamp?: number
56
hide?: boolean
67
title: string
78
// eslint-disable-next-line no-undef

libs/remix-ui/app/src/lib/remix-app/reducer/modals.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { AppModal, ModalState } from '../interface'
55
export const modalReducer = (state: ModalState = ModalInitialState, action: ModalAction) => {
66
switch (action.type) {
77
case modalActionTypes.setModal: {
8+
const timestamp = Date.now()
89
const focusModal: AppModal = {
9-
id: action.payload.id || Date.now().toString(),
10+
timestamp,
11+
id: action.payload.id || timestamp.toString(),
1012
hide: false,
1113
title: action.payload.title,
1214
message: action.payload.message,

libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export const ModalDialog = (props: ModalDialogProps) => {
2020
}
2121

2222
useEffect(() => {
23-
calledHideFunctionOnce.current = props.hide
23+
calledHideFunctionOnce.current = false
2424
modal.current.focus()
25-
}, [props.hide])
25+
}, [props.timestamp])
2626

2727
useEffect(() => {
2828
function handleBlur (e) {

libs/remix-ui/modal-dialog/src/lib/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-undef */
22
export interface ModalDialogProps {
33
id: string
4+
timestamp?: number,
45
title?: string,
56
message?: string | JSX.Element,
67
okLabel?: string,

0 commit comments

Comments
 (0)