Skip to content

feat(OneTable): add onHeaderClick to table column headers#4351

Open
FaithAdekunle wants to merge 2 commits into
mainfrom
feat/table-header-onclick
Open

feat(OneTable): add onHeaderClick to table column headers#4351
FaithAdekunle wants to merge 2 commits into
mainfrom
feat/table-header-onclick

Conversation

@FaithAdekunle

@FaithAdekunle FaithAdekunle commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

What

Adds an optional onHeaderClick callback to TableHead and to the OneDataCollection table column definition. When provided, the column header label becomes an interactive button.

Key points:

  • Independent of sortingonHeaderClick and onSortClick can coexist on the same header (the sort button remains separate).
  • The column-level prop is exposed via the existing Pick<ComponentProps<typeof TableHead>, …> in the table column type, so it flows through the existing {...column} spread in Table.tsx with no render changes.

Why

Consumers need to trigger an action scoped to a clicked column header — e.g. the Financial Workspace employee-cost table opens a workforce/headcount side panel when a month header is clicked. The legacy table supported this via a per-header onClick; the OneDataCollection table had no equivalent, so the behavior was lost in the migration. This restores that capability at the design-system level.

Changes

  • experimental/OneTable/TableHead/index.tsx — new onHeaderClick? prop; label renders as a focusable button when set.
  • patterns/OneDataCollection/visualizations/collection/Table/types.ts — expose onHeaderClick on the column definition.
  • Stories:
    • OneTableClickableHeader (incl. coexistence with sorting).
    • OneDataCollection Table → TableWithClickableHeaders (column-level API).

Follow-up (downstream)

Once released, bump @factorialco/f0-react in the factorial monolith and wire onHeaderClick into the Financial Workspace DataCollectionTable (separate PR).

Add an optional `onHeaderClick` callback to `TableHead` and the
OneDataCollection table column definition. When provided, the header
label becomes an interactive button, independent of sorting, so it can
coexist with `onSortClick`.

This enables consumers (e.g. Financial Workspace employee-cost tables)
to open a side panel scoped to the clicked column. Includes stories for
both the low-level OneTable and the OneDataCollection table column API.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added feat react Changes affect packages/react labels Jun 7, 2026
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

✅ No New Circular Dependencies

No new circular dependencies detected. Current count: 0

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

📦 Alpha Package Version Published

Use pnpm i github:factorialco/f0#npm/alpha-pr-4351 to install the package

Use pnpm i github:factorialco/f0#f41201ddfe73a1cb5e9cf26d6c5b7d3adf513e03 to install this specific commit

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🔍 Visual review for your branch is published 🔍

Here are the links to:

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

✅ No breaking public API changes

No public exports were removed, renamed, or had existing props/types changed in a breaking way compared to main.

Comparing f0, experimental and ai against main. Adding components, types, or optional props is safe. This check is non-blocking.

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for packages/react

Status Category Percentage Covered / Total
🔵 Lines 52.83% 15282 / 28924
🔵 Statements 51.96% 15860 / 30518
🔵 Functions 45.01% 3437 / 7636
🔵 Branches 45.8% 10809 / 23596
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/experimental/OneTable/TableHead/index.tsx 100% 90.27% 100% 100%
packages/react/src/patterns/OneDataCollection/visualizations/collection/Table/types.ts 100% 100% 100% 100%
Generated in workflow #14308 for commit ab0b4de by the Vitest Coverage Report Action

Add unit tests verifying the header label renders as a button and fires
onHeaderClick on click, that no button is rendered without the callback,
and that onHeaderClick works independently of sorting on the same column.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FaithAdekunle FaithAdekunle marked this pull request as ready for review June 8, 2026 08:16
@FaithAdekunle FaithAdekunle requested review from a team as code owners June 8, 2026 08:16
@albertpmz

Copy link
Copy Markdown

Could you please add a video demonstrating this new behavior? It'd be interesting to see how both the onClick trigger and sorting button coexist 🙏🏼

@FaithAdekunle

Copy link
Copy Markdown
Contributor Author

Could you please add a video demonstrating this new behavior? It'd be interesting to see how both the onClick trigger and sorting button coexist 🙏🏼

The header text itself serves as the onClick trigger while the sorting button remains as is.

Screenshare.-.2026-06-10.1_20_26.PM.mp4

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

Labels

feat react Changes affect packages/react

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants