Skip to content

Maintain value after dismiss modal #95

Description

@shifenis

As the title described, the modal should not remove the value while closing the modal: from the UX point of view, the user expects the X button will not delete his previous selection, but just dismiss the modal. I know there is a backButton, but even in this case, a modal (so a page that came from bottom to top) without navigation should not have a back arrow, because it assumes there is a page before and not behind it.

In fact, in the code you can find:

	private _onClose(): void {
		const { onClosed, onSelected, requireSelection, selected } = this.props;
		const { modalVisible, selectedObject } = this.state;

		if (requireSelection && (selectedObject && ![selectedObject.Id]) && (selected && ![selected.Id])) return;

		if (!requireSelection) {
			onSelected({} as IModalListInDto);
		}

		this.setState({
			selectedObject: {} as IModalListInDto, // RESETTING 
			modalVisible: !modalVisible,
		});
		this.clearComponent();
		if (onClosed) {
			onClosed();
		}
	}

As you can see, the state will update with an empty object when the user closes the modal.
So, after that, the question is: is an architecture behavior to clear the selectedObject?

Otherwise, I can even make a PR to update this.

Hoping my point it's clear.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions