table icon indicating copy to clipboard operation
table copied to clipboard

Table resetting when adding rows dynamically

Open ginnyedelstein opened this issue 7 years ago • 4 comments

Hi,

My table is resizable and I'm trying to add input rows through an onClick function using state/React, but when I do, the resized table shifts back to default size, presumably because it's rerendering when the state changes. Any advice?

ginnyedelstein avatar Mar 11 '19 18:03 ginnyedelstein

Figured out we have a very similar problem. We render a table with multiple inputs for rows which values are managed by onChange linked to the component's state that wraps React Table. After upgrading from 6.8.6 to 6.9.2, the behaviour of these inputs changed:

Before (6,8.6): able to write text in input fields continuously, with no interruption, having a relevant value held in the state.

After (6.9.2): on each change i.e. new character entered into the input field, the table gets reloaded with losing a focus.

A simple code snippet to reproduce: https://codesandbox.io/s/ywqko2x0r1 -- try writing something to the input field e.g. by pressing & holding the button.

One of the wild guesses is, the cells are being re-rendered with new keys, so React loses an element previously used for input. We'll investigate further if we can, but for now, had to roll back to 6.8.6.

sainnr avatar Mar 13 '19 11:03 sainnr

If you have questions about support or implementation, please use the React Table Spectrum Community

tannerlinsley avatar Mar 19 '19 19:03 tannerlinsley

Having the same

Figured out we have a very similar problem. We render a table with multiple inputs for rows which values are managed by onChange linked to the component's state that wraps React Table. After upgrading from 6.8.6 to 6.9.2, the behaviour of these inputs changed:

Before (6,8.6): able to write text in input fields continuously, with no interruption, having a relevant value held in the state.

After (6.9.2): on each change i.e. new character entered into the input field, the table gets reloaded with losing a focus.

A simple code snippet to reproduce: https://codesandbox.io/s/ywqko2x0r1 -- try writing something to the input field e.g. by pressing & holding the button.

One of the wild guesses is, the cells are being re-rendered with new keys, so React loses an element previously used for input. We'll investigate further if we can, but for now, had to roll back to 6.8.6.

Exact same issue. Resolved by using 6.8.6

coderavels avatar Mar 31 '19 17:03 coderavels

Also having the same problem re: the table re-rendering when I have an input as a table cell. Confirmed 6.8.6 seems to resolve the issue.

@tannerlinsley i'm not familiar with Spectrum but it seems weird to need to use a chat client to discuss a bug report, maybe you misunderstood the issue? Or maybe we should make a new issue here on GH to discuss the problem discussed after the OP, where the table seems to re-render when an input in a table cell is typed into?

ekilah avatar May 06 '19 22:05 ekilah