Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] documents: revert erased field input after alert dialog #166103

Draft
wants to merge 1 commit into
base: 17.0
Choose a base branch
from

Conversation

khpa-odoo
Copy link
Contributor

Steps to reproduce:

  • Go to list view or kanban view.
  • Select the document to preview in the inspector.
  • Clear the input value of a required field (here, Name or Workspace), and click elsewhere or press 'Enter'.
  • Discard/close the alert dialog.

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 of OK 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

@robodoo
Copy link
Contributor

robodoo commented May 20, 2024

@C3POdoo C3POdoo added the RD research & development, internal work label May 20, 2024
The main goal of this commit is to ensure that the confirmation dialog close
button is allowed to have a different behaviour than the discard button.
Because at present, it performs the same action as the discard button but
there might be cases when the dialog does not have a discard button and we
still want to handle the dialog close action.

To enable this, this commit adds an optional callback for dismiss operation
to the dialogData.dismiss that will only be executed when a dialog is closed
because of the "x" or the "escape" shortcut. Else, it will execute the callback
for cancel operation, if any.

Example Use Case:
- Go to list view or kanban view.
- Select the document to preview in the inspector.
- Clear the input value of a required field (here, Name or Workspace),
  and click out or press 'Enter'.
- Close the alert dialog via the "X" button or the "escape" shortcut.

Issue:
An alert dialog indicating a validation error is shown when a field value
is cleared. Yet, on closing the dialog, the unnamed document is saved as is.

Instead, the changes should be reverted.

Cause:
The close(dismiss) 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 upon closing dialog.

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 of
`OK` button, on dismissing the dialog 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
@khpa-odoo khpa-odoo force-pushed the 17.0-fix-prevent-saving-unnamed-documents-khpa branch from dc189ff to 499d765 Compare May 24, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants