Refactor initial dialog focus management
parent
6dafbf623e
commit
5e71f09e91
|
@ -123,9 +123,9 @@ export default {
|
|||
}
|
||||
},
|
||||
focus() {
|
||||
let focusable = DomHandler.getFocusableElements(this.$refs.dialog);
|
||||
if (focusable && focusable.length) {
|
||||
focusable[0].focus();
|
||||
let focusTarget = this.$refs.dialog.querySelector('[autofocus]');
|
||||
if (focusTarget) {
|
||||
focusTarget.focus();
|
||||
}
|
||||
},
|
||||
maximize() {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeBasic" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
|||
eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeBasic2" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic2" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic2" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeModal" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeModal" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeModal" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -64,7 +64,7 @@
|
|||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeMaximizable" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeMaximizable" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeMaximizable" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -92,7 +92,7 @@
|
|||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closePosition" class="p-button-text" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closePosition" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closePosition" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
|
|
@ -10,11 +10,8 @@ import Dialog from 'primevue/dialog';
|
|||
<h5>Getting Started</h5>
|
||||
<p>Dialog is used as a container and visibility is managed with <i>visible</i> property that requires the sync operator for two-way binding.</p>
|
||||
<CodeHighlight>
|
||||
<Dialog header="Godfather I" :visible.sync="display" >
|
||||
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
|
||||
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
|
||||
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
|
||||
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
|
||||
<Dialog header="Header" :visible.sync="display" >
|
||||
Content
|
||||
</Dialog>
|
||||
</CodeHighlight>
|
||||
|
||||
|
@ -31,7 +28,7 @@ export default {
|
|||
<h5>Header and Footer</h5>
|
||||
<p>Header and Footer sections are defined using properties with the same name that accept simple strings or with the <i>header</i> and <i>footer</i> templates for custom content.</p>
|
||||
<CodeHighlight>
|
||||
<Dialog header="Header Text" footer="Footer Text" :visible.sync="display">
|
||||
<Dialog header="Header" footer="Footer" :visible.sync="display">
|
||||
Content
|
||||
</Dialog>
|
||||
</CodeHighlight>
|
||||
|
@ -43,9 +40,10 @@ export default {
|
|||
</template>
|
||||
|
||||
Content
|
||||
|
||||
<template #footer>
|
||||
<Button label="Yes" icon="pi pi-check" />
|
||||
<Button label="No" icon="pi pi-times" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
</CodeHighlight>
|
||||
|
@ -64,6 +62,18 @@ export default {
|
|||
<Dialog :visible.sync="display" :contentStyle="{overflow: 'visible'}">
|
||||
Content
|
||||
</Dialog>
|
||||
</CodeHighlight>
|
||||
|
||||
<h5>Initial Focus</h5>
|
||||
<p>Adding <i>autofocus</i> to an element in the dialog makes it the initial focus target when dialog gets shown.</p>
|
||||
<CodeHighlight>
|
||||
<Dialog :visible.sync="display">
|
||||
Content
|
||||
<template #footer>
|
||||
<Button label="No" />
|
||||
<Button label="Yes" autofocus/>
|
||||
</template>
|
||||
</Dialog>
|
||||
</CodeHighlight>
|
||||
|
||||
<h5>Properties</h5>
|
||||
|
@ -242,7 +252,7 @@ export default {
|
|||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeBasic" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -264,7 +274,7 @@ export default {
|
|||
eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeBasic2" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic2" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeBasic2" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -276,7 +286,7 @@ export default {
|
|||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeModal" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeModal" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeModal" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -288,7 +298,7 @@ export default {
|
|||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closeMaximizable" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeMaximizable" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closeMaximizable" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
|
@ -316,7 +326,7 @@ export default {
|
|||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
<template #footer>
|
||||
<Button label="No" icon="pi pi-times" @click="closePosition" class="p-button-text"/>
|
||||
<Button label="Yes" icon="pi pi-check" @click="closePosition" />
|
||||
<Button label="Yes" icon="pi pi-check" @click="closePosition" autofocus />
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue