feat: add minScrollableWidth option to Table stickyColumns#4812
Draft
ernst-dev wants to merge 1 commit into
Draft
feat: add minScrollableWidth option to Table stickyColumns#4812ernst-dev wants to merge 1 commit into
ernst-dev wants to merge 1 commit into
Conversation
The stickyColumns feature silently deactivates when the remaining scrollable space drops below a hard-coded 148px threshold, with no way for consumers to influence it. This adds an opt-in stickyColumns.minScrollableWidth to override that minimum, allowing the first (or last) column(s) to stay pinned on narrower tables (e.g. set to 0) or to deactivate sooner. The option is threaded through useStickyColumns into the enablement check and defaults to the existing MINIMUM_SCROLLABLE_SPACE, so behavior is unchanged when the property is omitted (backward compatible). Adds unit tests and a dev page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4812 +/- ##
=======================================
Coverage 97.61% 97.61%
=======================================
Files 952 952
Lines 30816 30818 +2
Branches 11318 11320 +2
=======================================
+ Hits 30081 30083 +2
Misses 688 688
Partials 47 47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds an opt-in
stickyColumns.minScrollableWidthoption to the Table component so consumers can control the minimum scrollable space that must remain next to the sticky columns for the feature to stay active.Background — this fills a gap in the existing feature, it does not add a new one. The Table already fully supports sticky first (and last) columns via
stickyColumns={{ first, last }}. However, the feature silently deactivates whenever the remaining scrollable space drops below a hard-coded148px(MINIMUM_SCROLLABLE_SPACE), and there is no way for a consumer to influence that threshold. On narrower tables this means a first column that the developer explicitly asked to pin simply stops being sticky, with no signal.This PR exposes that threshold:
TableProps.StickyColumns.minScrollableWidth?: number(pixels).useStickyColumnsinto the enablement check (isEnabled).MINIMUM_SCROLLABLE_SPACE(148) when omitted — fully backward compatible, no behavior change for existing consumers.Files touched:
src/table/interfaces.tsx— publicStickyColumns.minScrollableWidth+ doc comment.src/table/sticky-columns/interfaces.ts— internalStickyColumnsProps.minScrollableWidth.src/table/sticky-columns/use-sticky-columns.ts— plumbed into the store +isEnabledguard.src/table/internal.tsx— passes the prop from the public API into the hook.pages/table/sticky-columns-min-scrollable-width.page.tsx— new dev page.Related links, issue #, if available: SIM AWSUI-61614 (see mismatch note above)
How has this been tested?
src/table/sticky-columns/__tests__/use-sticky-columns.test.tsx:minScrollableWidth=0keeps sticky columns active when the default 148px threshold would deactivate them.minScrollableWidthdeactivates sticky columns even when the default threshold would allow them.npm run quick-buildand fullgulp buildsucceed; ESLint clean on all touched files.#/light/table/sticky-columns-min-scrollable-width), togglingminScrollableWidthon a narrow (600px) horizontally-scrollable table.Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.