From ab208ecc2d7ebf8b8c9801eb75c16c0cc25b7154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Thu, 11 Nov 2021 14:20:44 +0300 Subject: [PATCH] Fixed #1663 - Default focus button should be configurable for ConfirmDialog --- src/components/confirmdialog/ConfirmDialog.vue | 11 +++++++++-- src/views/confirmdialog/ConfirmDialogDoc.vue | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/confirmdialog/ConfirmDialog.vue b/src/components/confirmdialog/ConfirmDialog.vue index ebfc9031e..d4fe0ca34 100644 --- a/src/components/confirmdialog/ConfirmDialog.vue +++ b/src/components/confirmdialog/ConfirmDialog.vue @@ -4,8 +4,8 @@ {{message}} @@ -104,6 +104,13 @@ export default { }, rejectClass() { return ['p-confirm-dialog-reject', this.confirmation ? (this.confirmation.rejectClass || 'p-button-text') : null]; + }, + autoFocusAccept() { + return this.confirmation.defaultFocus === 'accept' ? true : false; + }, + autoFocusReject() { + // backward compatibility + return this.confirmation.defaultFocus !== 'accept' ? true : false; } }, components: { diff --git a/src/views/confirmdialog/ConfirmDialogDoc.vue b/src/views/confirmdialog/ConfirmDialogDoc.vue index 40ec02a9c..b17e807df 100644 --- a/src/views/confirmdialog/ConfirmDialogDoc.vue +++ b/src/views/confirmdialog/ConfirmDialogDoc.vue @@ -192,6 +192,12 @@ export default { true Whether background scroll should be blocked when dialog is visible. + + defaultFocus + string + null + Element to receive the focus when the dialog gets visible, valid values are "accept" and "reject". +