Skip to content

Commit

Permalink
fix(VDialog): emit afterEnter before setting focus
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD authored and jsek committed Aug 25, 2024
1 parent b861d8c commit 62a2c9d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/vuetify/src/components/VDialog/VDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const VDialog = genericComponent<OverlaySlots>()({

emits: {
'update:modelValue': (value: boolean) => true,
afterEnter: () => true,
afterLeave: () => true,
},

Expand Down Expand Up @@ -89,6 +90,7 @@ export const VDialog = genericComponent<OverlaySlots>()({
}

function onAfterEnter () {
emit('afterEnter')
if (overlay.value?.contentEl && !overlay.value.contentEl.contains(document.activeElement)) {
overlay.value.contentEl.focus({ preventScroll: true })
}
Expand Down
2 changes: 2 additions & 0 deletions packages/vuetify/src/components/VTreeview/VTreeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
filterTreeItems,
filterTreeItem,
} from './util/filterTreeItems'
import { preventLoops } from '@/util/nested'

type VTreeviewNodeInstance = InstanceType<typeof VTreeviewNode>

Expand Down Expand Up @@ -307,6 +308,7 @@ export default mixins(

const parents = []
while (parent !== null) {
preventLoops(parents, parent)
parents.push(parent)
parent = this.nodes[parent].parent
}
Expand Down
2 changes: 2 additions & 0 deletions packages/vuetify/src/composables/nested/nested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
leafSingleSelectStrategy,
} from './selectStrategies'
import { getCurrentInstance, getUid, propsFactory } from '@/util'
import { preventLoops } from '@/util/nested'

// Types
import type { InjectionKey, PropType, Ref } from 'vue'
Expand Down Expand Up @@ -182,6 +183,7 @@ export const useNested = (props: NestedProps) => {
let parent: unknown = id

while (parent != null) {
preventLoops(path, parent)
path.unshift(parent)
parent = parents.value.get(parent)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/vuetify/src/labs/VTreeview/VTreeview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useProxiedModel } from '@/composables/proxiedModel'
// Utilities
import { computed, provide, ref, toRaw, toRef } from 'vue'
import { genericComponent, omit, propsFactory, useRender } from '@/util'
import { preventLoops } from '@/util/nested'

// Types
import { VTreeviewSymbol } from './shared'
Expand Down Expand Up @@ -98,6 +99,7 @@ export const VTreeview = genericComponent<new <T>(
const path: unknown[] = []
let parent: unknown = id
while (parent != null) {
preventLoops(path, parent)
path.unshift(parent)
parent = vListRef.value?.parents.get(parent)
}
Expand Down

0 comments on commit 62a2c9d

Please sign in to comment.