Skip to content

Commit

Permalink
Fix/close confirm modal (#4431)
Browse files Browse the repository at this point in the history
* fix: hide close confirm modal on specific modals

* refactor: remove hideModalWithoutConfirmModal and migrate it into hideModal

* feat: hide modal directly with error or success state

* fix: hide modal criteria

* fix: type issue and hide criteria

* fix: update hideModal action for two modals

* fix hideModal param

Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>

* Remove unrelated changes

Co-authored-by: l1.media <31551045+traumschule@users.noreply.github.com>

---------

Co-authored-by: gyroflaw <83718263+gyroflaw@users.noreply.github.com>
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
  • Loading branch information
3 people authored Jun 14, 2023
1 parent 5c3bcac commit 27a9190
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/ui/src/common/providers/modal/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const ModalContextProvider = (props: Props) => {
const [modalData, setModalData] = useState<any>()
const [currentModalMachine, setCurrentModalMachine] = useState<UnknownMachine<any, any, any> | undefined>(undefined)
const [isClosing, setIsClosing] = useState<boolean>(false)

const modalApi: UseModal<AnyModalCall> = {
showModal: (modalCall) => {
setModal(modalCall.modal)
Expand All @@ -25,7 +26,12 @@ export const ModalContextProvider = (props: Props) => {
}
},
hideModal: () => {
if (isClosing || !MODAL_WITH_CLOSE_CONFIRMATION.includes((modal ?? '') as ModalNames)) {
const [state] = currentModalMachine ?? []
if (
isClosing ||
!MODAL_WITH_CLOSE_CONFIRMATION.includes((modal ?? '') as ModalNames) ||
state?.matches('success')
) {
setModal(null)
setModalData(null)
setCurrentModalMachine(undefined)
Expand Down

2 comments on commit 27a9190

@vercel
Copy link

@vercel vercel bot commented on 27a9190 Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 27a9190 Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pioneer-2 – ./

pioneer-2-git-dev-joystream.vercel.app
pioneer-2.vercel.app
pioneer-2-joystream.vercel.app

Please sign in to comment.