Skip to content

Persist DataTable column visibility using useLocalStorage#61280

Closed
sanchalitorpe13 wants to merge 1 commit into
apache:mainfrom
sanchalitorpe13:persist-datatable-column-visibility-clean
Closed

Persist DataTable column visibility using useLocalStorage#61280
sanchalitorpe13 wants to merge 1 commit into
apache:mainfrom
sanchalitorpe13:persist-datatable-column-visibility-clean

Conversation

@sanchalitorpe13

Copy link
Copy Markdown

This PR adds persistence for column visibility (show/hide) in all DataTable components in the Airflow UI. Users’ column preferences are now saved in browser localStorage, so when they revisit a table, their previous column selections are restored automatically.

Key points:

  • Only column visibility is persisted — sorting, filtering, and pagination remain unchanged.
  • Uses the existing useLocalStorage hook for consistency with other UI state persistence.
  • Scope of persistence is based on the table modelName, ensuring different tables store separate configurations.
  • Falls back to default column visibility if no stored configuration is found.

Testing

  • Manually verified hiding/showing columns in multiple tables.
  • Reloading the page preserves column visibility as expected.

Related Issue
Closes: #61159

@boring-cyborg boring-cyborg Bot added the area:UI Related to UI/UX. For Frontend Developers. label Jan 31, 2026
@pierrejeambrun pierrejeambrun added this to the Airflow 3.2.0 milestone Feb 5, 2026

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Do you mind respecting the issue template, and not remove the 'did you use any AI tools' . That's part of our contributing policy and help reviewers review process.

<!--
If generative AI tooling has been used in the process of authoring this PR, please
change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
-->

- [ ] Yes (please specify the tool below)

Guidelines for using AI https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

It's almost correct but needs adjustment to work.

Please make sure you test your changes before submitting the PR.

* under the License.
*/

import { useLocalStorage } from 'src/utils/useLocalStorage';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't exists. Import path is wrong.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct one is

import { useLocalStorage } from "usehooks-ts";

initialState?.columnVisibility ?? {},
);
const [columnVisibility, setColumnVisibility] = useLocalStorage<VisibilityState>(
'datatable:${modelName}:columnVisibility',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't work like this, you are not doing interpolation.

Suggested change
'datatable:${modelName}:columnVisibility',
`dataTable:${modelName}:columnVisibility`,

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was AI generated and we have no response from the contributor. Closing in favor of #61858

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save tables columns configuration

3 participants