Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable: createResponsiveStyle not called on scrollable property change #3694

Closed
rschyboll opened this issue Nov 23, 2022 · 1 comment · Fixed by #3697
Closed

DataTable: createResponsiveStyle not called on scrollable property change #3694

rschyboll opened this issue Nov 23, 2022 · 1 comment · Fixed by #3697
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@rschyboll
Copy link
Contributor

Describe the bug

As in the title, the DataTable component, does not call internally the createResponsiveStyle function, when changing the scrollable property. As a result, it is not possible to change the DataTable layout from scrollable, to stack.

I encountered this issue when searching for a workaround to this issue #3639.
Currently, the only way to make it working, is to prevent setting scrollable to true on the first render, using some state variable and relasing the lock after a setTimeout(..., 0).

Reproducer

https://codesandbox.io/s/relaxed-snow-gclho9?file=/src/demo/DataTableResponsiveDemo.js

PrimeReact version

8.7.2

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Chrome 90

Steps to reproduce the behavior

  1. Create a DataTable with the following properties:
  <DataTable
      breakpoint={//Some breakpoint value}
      responsiveLayout="stack"
      scrollable={scrollable}
    >

Where scrollable is some kind of state.
2. The scrollable parameter on the start needs to be set to true.
3. Changing the scrollable parameter when the window is smaller than the breakpoint

Expected behavior

The component should generate the needed style when changing the scrollable property.
After some digging, it seems that there is a useEffect missing, that would react to changes in this property, and generate this style.

@rschyboll rschyboll added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 23, 2022
melloware added a commit to melloware/primereact that referenced this issue Nov 23, 2022
@melloware melloware added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 23, 2022
@melloware melloware self-assigned this Nov 23, 2022
@melloware melloware added this to the 8.7.3 milestone Nov 23, 2022
@melloware
Copy link
Member

Thanks for the report! Please review my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants