nuxt / nuxt/ui

UTable row data-selectable attribute not aligned with TanStack API

Open
#4,968 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
6.9k
Forks
1.1k
Avg merge
1d 7h
Merged PRs (30d)
57

Description

Environment

All environments

Is this bug related to Nuxt or Vue?

Nuxt

Package

v4.0.0-alpha.x

Version

v4.0.0-alpha.1

Reproduction

I'm quite sure that the issue is obvious and provided information is enough to understand the problem.

Description

Currently the UTable row data-selectable attribute is based on this

<tr :data-selectable="!!props.onSelect || !!props.onHover || !!props.onContextmenu">

I want to have some of the items in the table to be non-selectable (and inert to hover) and adjust styling accordingly via

// Desired
<UTable 
  :rowSelectionOptions="{ enableRowSelection: row => row.original.isDisabled }"
  :meta="{ class: { tr: row => row.getCanSelect() ? 'cursor-pointer' : 'bg-accented' } }" />

instead of

// Current workaround
<UTable
  :meta="{ class: {
     tr: row => (row.getCanSelect()
        ? 'cursor-pointer'
        : 'data-[selectable=true]:!bg-accented data-[selectable=true]:hover:!bg-accented'),
  } }"
/>

I understand the need to have some sensible defaults, but I propose changing this to

<tr :data-selectable="!!props.rowSelectionOptions?.enableRowSelection 
   ? row.getCanSelect() : !!props.onSelect || !!props.onHover || !!props.onContextmenu">

p.s. Many thanks for all this beautiful work you have done so far.

Additional context

No response

Logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the UTable row rendering and its rowSelectionOptions handling, then compare the data-selectable attribute with TanStack's row.getCanSelect() behavior described in the issue. Done means disabled rows are not treated as selectable or hoverable, while existing onSelect, onHover, and onContextmenu behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, tailwindcss, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.