Skip to content

Commit

Permalink
Added sorting interaction on enter press
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush.arora committed Feb 6, 2025
1 parent eb82be7 commit 9de6a0d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
top: (props.sticky || props.fixedHeader) ? `calc(var(--v-table-header-height) * ${y})` : undefined,
}
}

function handleEnterKeyPress (event: KeyboardEvent, column: InternalDataTableHeader) {
if (event.key === 'Enter' && !props.disableSort) {
toggleSort(column)
}
}
function getSortIcon (column: InternalDataTableHeader) {
const item = sortBy.value.find(item => item.key === column.key)

Expand Down Expand Up @@ -166,6 +170,7 @@ export const VDataTableHeaders = genericComponent<VDataTableHeadersSlots>()({
lastFixed={ column.lastFixed }
noPadding={ noPadding }
{ ...headerProps }
onKeydown={ (event: KeyboardEvent) => column.sortable && handleEnterKeyPress(event, column) }
>
{{
default: () => {
Expand Down

0 comments on commit 9de6a0d

Please sign in to comment.