Skip to content

Commit ec6f80a

Browse files
authored
Merge branch 'master' into haviles04/v-select-header-slot
2 parents 25cf81a + b58e361 commit ec6f80a

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

packages/docs/src/components/app/search/SearchDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
function transformItems (items: any[]) {
160160
// const sorted = sortItems([...items], ['hierarchy.lvl0', 'hierarchy.lvl1'], [false, false], locale)
161161
items = items.map(item => {
162-
const url = new URL(item.url)
162+
const url = new URL(item.url_without_variables)
163163
164164
return {
165165
...item,

packages/docs/src/components/examples/Example.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@
246246
path: 'edit-in-playground',
247247
href: playgroundLink.value,
248248
target: '_blank',
249-
hide: xs.value,
250249
},
251250
{
252251
icon: '$vuetify-figma',

packages/vuetify/src/components/VDataTable/VDataTableRows.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const VDataTableRows = genericComponent<new <T>(
143143
}
144144

145145
const slotProps = {
146-
index,
146+
index: item.virtualIndex ?? index,
147147
item: item.raw,
148148
internalItem: item,
149149
columns: columns.value,

packages/vuetify/src/components/VDataTable/VDataTableVirtual.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,14 @@ export const VDataTableVirtual = genericComponent<new <T extends readonly any[],
141141
calculateVisibleItems,
142142
scrollToIndex,
143143
} = useVirtual(props, flatItems)
144-
const displayItems = computed(() => computedItems.value.map(item => item.raw))
144+
145+
const displayItems = computed(() =>
146+
computedItems.value
147+
.map(item => ({
148+
...item.raw,
149+
virtualIndex: item.index,
150+
}))
151+
)
145152

146153
useOptions({
147154
sortBy,
@@ -249,7 +256,7 @@ export const VDataTableVirtual = genericComponent<new <T extends readonly any[],
249256
{ ...itemSlotProps.props }
250257
ref={ itemRef }
251258
key={ itemSlotProps.internalItem.index }
252-
index={ itemSlotProps.internalItem.index }
259+
index={ itemSlotProps.index }
253260
v-slots={ slots }
254261
/>
255262
)

packages/vuetify/src/components/VDataTable/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export type InternalDataTableHeader = Omit<DataTableHeader, 'key' | 'value' | 'c
4949
export interface DataTableItem<T = any> extends Omit<InternalItem<T>, 'type'>, GroupableItem<T>, SelectableItem {
5050
key: any
5151
index: number
52+
virtualIndex?: number
5253
columns: {
5354
[key: string]: any
5455
}

packages/vuetify/src/components/VDatePicker/VDatePickerYears.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useProxiedModel } from '@/composables/proxiedModel'
1212
import vIntersect from '@/directives/intersect'
1313

1414
// Utilities
15-
import { computed, watchEffect } from 'vue'
15+
import { computed, shallowRef, watchEffect } from 'vue'
1616
import { convertToUnit, createRange, genericComponent, propsFactory, templateRef, useRender } from '@/util'
1717

1818
// Types
@@ -60,6 +60,7 @@ export const VDatePickerYears = genericComponent<VDatePickerYearsSlots>()({
6060
setup (props, { emit, slots }) {
6161
const adapter = useDate()
6262
const model = useProxiedModel(props, 'modelValue')
63+
const hasFocusedItem = shallowRef(false)
6364
const years = computed(() => {
6465
const year = adapter.getYear(adapter.date())
6566

@@ -97,7 +98,6 @@ export const VDatePickerYears = genericComponent<VDatePickerYearsSlots>()({
9798
const yearRef = templateRef()
9899

99100
function focusSelectedYear () {
100-
yearRef.el?.focus()
101101
yearRef.el?.scrollIntoView({ block: 'center' })
102102
}
103103

@@ -123,7 +123,13 @@ export const VDatePickerYears = genericComponent<VDatePickerYearsSlots>()({
123123
height: convertToUnit(props.height),
124124
}}
125125
>
126-
<div class="v-date-picker-years__content">
126+
<div
127+
class="v-date-picker-years__content"
128+
onFocus={ () => yearRef.el?.focus() }
129+
onFocusin={ () => hasFocusedItem.value = true }
130+
onFocusout={ () => hasFocusedItem.value = false }
131+
tabindex={ hasFocusedItem.value ? -1 : 0 }
132+
>
127133
{ years.value.map((year, i) => {
128134
const btnProps = {
129135
ref: model.value === year.value ? yearRef : undefined,

packages/vuetify/src/composables/nested/nested.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ type NestedProvide = {
9292
itemsRegistration: Ref<ItemsRegistrationType>
9393
register: (id: unknown, parentId: unknown, isDisabled: boolean, isGroup?: boolean) => void
9494
unregister: (id: unknown) => void
95+
updateDisabled: (id: unknown, isDisabled: boolean) => void
9596
open: (id: unknown, value: boolean, event?: Event) => void
9697
activate: (id: unknown, value: boolean, event?: Event) => void
9798
select: (id: unknown, value: boolean, event?: Event) => void
@@ -108,6 +109,7 @@ export const emptyNested: NestedProvide = {
108109
itemsRegistration: ref('render'),
109110
register: () => null,
110111
unregister: () => null,
112+
updateDisabled: () => null,
111113
children: ref(new Map()),
112114
parents: ref(new Map()),
113115
disabled: ref(new Set()),
@@ -330,6 +332,19 @@ export const useNested = (props: NestedProps, items: Ref<ListItem[]>, returnObje
330332
parents.value.delete(id)
331333
itemsUpdatePropagation()
332334
},
335+
updateDisabled: (id, isDisabled) => {
336+
if (isDisabled) {
337+
disabled.value.add(id)
338+
} else {
339+
disabled.value.delete(id)
340+
}
341+
// classic selection requires refresh to re-evaluate on/off/indeterminate but
342+
// currently it is only run for selection interactions, so it will set new disabled
343+
// to "off" and the visual state becomes out of sync
344+
// -- selected.value = new Map(selected.value)
345+
// it is not clear if the framework should un-select when disabled changed to true
346+
// more discussion is needed
347+
},
333348
open: (id, value, event) => {
334349
vm.emit('click:open', { id, value, path: getPath(id), event })
335350

@@ -462,6 +477,10 @@ export const useNestedItem = (id: MaybeRefOrGetter<unknown>, isDisabled: MaybeRe
462477
})
463478
})
464479

480+
watch(() => toValue(isDisabled), val => {
481+
parent.root.updateDisabled(computedId.value, val)
482+
})
483+
465484
isGroup && provide(VNestedSymbol, item)
466485

467486
return item

0 commit comments

Comments
 (0)