Skip to content

[Request] Possibility of calling modal.resolve/modal.reject after modal.hide #177

@qwelol

Description

@qwelol

Description:

In the current implementation, calling modal.resolve() is only possible before calling modal.hide(). This is because modal.hide() clears the internal promise array during its execution.

delete modalCallbacks[modalId];

However, when animations are involved, it’s often desirable to resolve() the modal’s promise after the hide animation has completed. This prevents potential conflicts or visual glitches that might occur if another animation is triggered immediately after the modal starts closing.

Example:

// modal component 
const handleClose = () => {
    modal.resolve();
    modal.hide();  // modal animation started
}

// external call 
modal.show().then(() => {
// another animation started in parallel
})

Possible Solution:

  • Consider allowing modal.resolve() to be called after modal.hide() without causing issues.
  • Expose a new method, for example modal.resolveHide(), to handle this use case

Expected behavior (mu5 for example):

// dialog props 
{
    open: modal.visible,
    onClose: () => modal.hide().then(() => {
		// resolve show 
		modal.resolve();
		!modal.keepMounted && modal.remove();
	}),
    TransitionProps: {
      onExited: () => {
	// animation ended
        modal.resolveHide();
      },
    },
  };
};

// external call 
modal.show().then(() => {
// another animation started
})

P/s: Am I missing something, and is this behavior already achievable in the current implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions