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 7e9a1b7 commit caa1cd8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
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
9 changes: 9 additions & 0 deletions packages/vuetify/src/util/nested.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function preventLoops<T> (path: T[] | Set<T> | Map<T, any>, itemToPush: T) {
if (
(Array.isArray(path) && path.includes(itemToPush)) ||
(path instanceof Set && path.has(itemToPush)) ||
(path instanceof Map && path.has(itemToPush))
) {
throw new Error('[Vuetify] Could not resolve nested path because of duplicated identifiers')
}
}

0 comments on commit caa1cd8

Please sign in to comment.