[FIX] documents: revert erased field input after alert dialog #166103
+7
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Steps to reproduce:
Issue:
An alert dialog indicating a validation error is shown when a field value is cleared. Yet, on closing the dialog or clicking on 'Cancel', the unnamed document is saved as is.
Instead, the changes should be reverted.
Cause:
The close/cancel operation is never handled in case of alert dialog for invalid selection. Hence, by default, it applies the changes made to the field.
Fix:
The alert dialog for invalid selection is different from the ones which are simply used to display warnings or alert messages because they do not need to perform any action.
In this case, we want to prevent any invalid changes from being applied. It is achieved by calling the
leaveEditMode
method which discards them and switches the config mode. Hence, we do something similar to what is done on the click ofOK
button, for the click of `Cancel/Close`` buttons as well. This behvaior is introduced because even if user discards the dialog, any change which is not valid should not be applied.Task: 3799280