Fixed #1663 - Default focus button should be configurable for ConfirmDialog

pull/1751/head
Tuğçe Küçükoğlu 2021-11-11 14:20:44 +03:00
parent 2134166472
commit ab208ecc2d
2 changed files with 15 additions and 2 deletions

View File

@ -4,8 +4,8 @@
<i :class="iconClass" />
<span class="p-confirm-dialog-message">{{message}}</span>
<template #footer>
<CDButton :label="rejectLabel" :icon="rejectIcon" :class="rejectClass" @click="reject()"/>
<CDButton :label="acceptLabel" :icon="acceptIcon" :class="acceptClass" @click="accept()" autofocus />
<CDButton :label="rejectLabel" :icon="rejectIcon" :class="rejectClass" @click="reject()" :autofocus="autoFocusReject"/>
<CDButton :label="acceptLabel" :icon="acceptIcon" :class="acceptClass" @click="accept()" :autofocus="autoFocusAccept" />
</template>
</CDialog>
</template>
@ -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: {

View File

@ -192,6 +192,12 @@ export default {
<td>true</td>
<td>Whether background scroll should be blocked when dialog is visible.</td>
</tr>
<tr>
<td>defaultFocus</td>
<td>string</td>
<td>null</td>
<td>Element to receive the focus when the dialog gets visible, valid values are "accept" and "reject".</td>
</tr>
</tbody>
</table>
</div>