primefaces / primefaces/primereact

DataTable: focus issue on cell editors

Open
#6,800 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

I use 'editor' prop on a column which renders a text input when in an edition mode. Whenever the change in input causes a rerender of my DataTable (e.g. by udpating my custom context I'm using for whatever reason), the input loses focus - the Save icon steals the focus.

I've finally found the culprit: https://github.com/primefaces/primereact/blob/master/components/lib/datatable/BodyCell.js#L230
For some reason this function is called on every rerender when we are in the edit mode. When I comment out the body of this fn, the text input no longer loses focus and everything works nice.

I want to understand what is the reasoning behind adding such logic and if it's ok to add/use a props (e.g. selectionAutoFocus) to disable this behavior.

If you need a repro, I will create one shortly.

Reproducer

No response

PrimeReact version

10.5.1

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

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 in components/lib/datatable/BodyCell.js around line 230 and trace why the focus-related function runs during DataTable rerenders in cell edit mode. Reproduce the reported editor update with PrimeReact 10.5.1 and React 18.x, then verify that changing the input no longer moves focus to the Save icon.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.