primefaces / primefaces/primereact
DataTable: focus issue on cell editors
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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