primefaces / primefaces/primereact

DataTable: Column header always rendered in a span element

Open
#8,291 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs Triage
Dominant language
CSS
Stars
8.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Passing a custom header element to the Column always renders it inside the <span>, which is often not correct for accessibility. A lot of elements can not be rendered as children of span e.g. div.

Reproducer

https://stackblitz.com/edit/xuskzp8u

System Information
primereact: 10.9.7
Steps to reproduce the behavior
  1. Create a DataTable
  2. In one of the columns provide a header prop that is not a simple string value, but a function returning some element e.g.
  3. Inspect page. Notice that the is rendered inside a which is not correct.
Expected behavior

If the custom header is provided it should render it inside a div instead of span to maintain correct accessibility.

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 with the DataTable and Column header rendering used by the linked StackBlitz reproducer, then trace where custom header content is wrapped. Confirm the current markup for string and element headers, and verify that custom elements no longer receive an invalid span wrapper while ordinary headers retain their expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
react
Domain
accessibility, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.