primereact icon indicating copy to clipboard operation
primereact copied to clipboard

DataTable: focus issue on cell editors

Open MBelniak opened this issue 1 year ago • 0 comments

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

MBelniak avatar Jun 27 '24 09:06 MBelniak