Commit ee7a3427 authored by Rachel Sugrono's avatar Rachel Sugrono Committed by Commit Bot

[quickview] Enclose <cr-dialog> in a <dialog> :)

Enclose |cr-dialog-container| in a <dialog> (delete-confirm-dialog) to
ensure that tab index always remains within the <cr-dialog>. Also stop
keydown event propagation to stop them passing out of the <dialog> for
the same reasons.

Implement the functions |showModalElement| and |doneCallback| to show
and close the <dialog>, respectively.

Minor: Change parameter type from HTMLElement to Element on the
FilesConfirmDialog interface.

Bug: 803259
Change-Id: Iea2482c017804e873e0ab0f23b8d7bfe2ba3ca1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033012
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737683}
parent 67736442
...@@ -1017,11 +1017,14 @@ CommandHandler.COMMANDS_['delete'] = new class extends Command { ...@@ -1017,11 +1017,14 @@ CommandHandler.COMMANDS_['delete'] = new class extends Command {
if (!dialog) { if (!dialog) {
dialog = fileManager.ui.deleteConfirmDialog; dialog = fileManager.ui.deleteConfirmDialog;
} else if (dialog.showModalElement) {
dialog.showModalElement();
} }
dialog.show(message, () => { dialog.show(message, () => {
dialog.doneCallback && dialog.doneCallback();
fileManager.fileOperationManager.deleteEntries(entries); fileManager.fileOperationManager.deleteEntries(entries);
}, null, null); }, dialog.doneCallback, null);
} }
/** /**
......
...@@ -279,10 +279,24 @@ class QuickViewController { ...@@ -279,10 +279,24 @@ class QuickViewController {
// Create a delete confirm dialog if needed. // Create a delete confirm dialog if needed.
if (!this.deleteConfirmDialog_) { if (!this.deleteConfirmDialog_) {
const parent = this.quickView_.shadowRoot.getElementById('dialog'); const dialogElement = document.createElement('dialog');
assert(parent); this.quickView_.shadowRoot.appendChild(dialogElement);
this.deleteConfirmDialog_ = new FilesConfirmDialog(parent); dialogElement.id = 'delete-confirm-dialog';
this.deleteConfirmDialog_ = new FilesConfirmDialog(dialogElement);
this.deleteConfirmDialog_.setOkLabel(str('DELETE_BUTTON_LABEL')); this.deleteConfirmDialog_.setOkLabel(str('DELETE_BUTTON_LABEL'));
dialogElement.addEventListener('keydown', event => {
event.stopPropagation();
});
this.deleteConfirmDialog_.showModalElement = function() {
dialogElement.showModal();
};
this.deleteConfirmDialog_.doneCallback = function() {
dialogElement.close();
};
} }
// Delete the entry. // Delete the entry.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
*/ */
class FilesConfirmDialog extends cr.ui.dialogs.ConfirmDialog { class FilesConfirmDialog extends cr.ui.dialogs.ConfirmDialog {
/** /**
* @param {!HTMLElement} parentElement * @param {!Element} parentElement
*/ */
constructor(parentElement) { constructor(parentElement) {
super(parentElement); super(parentElement);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment