feat(Page): add dynamic sticky section support#12409
feat(Page): add dynamic sticky section support#12409wise-king-sullyman wants to merge 1 commit intopatternfly:mainfrom
Conversation
WalkthroughThis PR adds sticky positioning support to ChangesSticky Positioning Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
|
Preview: https://pf-react-pr-12409.surge.sh A11y report: https://pf-react-pr-12409-a11y.surge.sh |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/react-core/src/components/Page/PageGroup.tsx (1)
57-62: ⚡ Quick winConsider adding a dev warning when
isStickyStuckis set withoutstickyBaseBoth components already follow the pattern of warning via
useEffectwhen a prop combination is a silent no-op (e.g.,hasOverflowScroll+ noaria-label).isStickyStuck=truewithoutstickyBaseapplies no CSS classes — a console warning would surface this misconfiguration consistently.💡 Suggested addition (mirroring the existing pattern)
useEffect(() => { if (hasOverflowScroll && !ariaLabel) { /* eslint-disable no-console */ console.warn('PageGroup: An accessible aria-label is required when hasOverflowScroll is set to true.'); } + if (isStickyStuck && !stickyBase) { + /* eslint-disable no-console */ + console.warn('PageGroup: isStickyStuck has no effect without stickyBase also being set.'); + } - }, [hasOverflowScroll, ariaLabel]); + }, [hasOverflowScroll, ariaLabel, isStickyStuck, stickyBase]);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/react-core/src/components/Page/PageGroup.tsx` around lines 57 - 62, The component should emit a dev-time console warning when isStickyStuck is true but stickyBase is not provided because that prop combination is a silent no-op; inside the existing useEffect block in PageGroup (or a nearby useEffect that watches prop combos), add a check for isStickyStuck && !stickyBase and call console.warn with a clear message (e.g., "PageGroup: isStickyStuck is set to true but stickyBase is not provided — this will have no effect.") so developers see the misconfiguration; reference the isStickyStuck and stickyBase props and ensure the effect depends on [isStickyStuck, stickyBase].packages/react-core/src/components/Page/PageSection.tsx (1)
117-122: ⚡ Quick winSame
isStickyStuckwithoutstickyBasewarning applies here.Same as
PageGroup— consider adding aconsole.warninside the existinguseEffectwhenisStickyStuck && !stickyBaseto keep the DX pattern consistent across both components.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/react-core/src/components/Page/PageSection.tsx` around lines 117 - 122, In PageSection's useEffect add the same developer experience warning as PageGroup: when isStickyStuck is true and stickyBase is falsy, call console.warn to inform developers to provide stickyBase; update the existing effect that currently checks hasOverflowScroll and ariaLabel (function/component: PageSection, hook: useEffect, props/vars: hasOverflowScroll, ariaLabel, isStickyStuck, stickyBase) to also perform a conditional console.warn for isStickyStuck && !stickyBase so the pattern is consistent across components.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/react-core/src/components/Page/PageGroup.tsx`:
- Around line 57-62: The component should emit a dev-time console warning when
isStickyStuck is true but stickyBase is not provided because that prop
combination is a silent no-op; inside the existing useEffect block in PageGroup
(or a nearby useEffect that watches prop combos), add a check for isStickyStuck
&& !stickyBase and call console.warn with a clear message (e.g., "PageGroup:
isStickyStuck is set to true but stickyBase is not provided — this will have no
effect.") so developers see the misconfiguration; reference the isStickyStuck
and stickyBase props and ensure the effect depends on [isStickyStuck,
stickyBase].
In `@packages/react-core/src/components/Page/PageSection.tsx`:
- Around line 117-122: In PageSection's useEffect add the same developer
experience warning as PageGroup: when isStickyStuck is true and stickyBase is
falsy, call console.warn to inform developers to provide stickyBase; update the
existing effect that currently checks hasOverflowScroll and ariaLabel
(function/component: PageSection, hook: useEffect, props/vars:
hasOverflowScroll, ariaLabel, isStickyStuck, stickyBase) to also perform a
conditional console.warn for isStickyStuck && !stickyBase so the pattern is
consistent across components.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a3d6c913-721c-4f8e-a1ef-1f10fbe9301b
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (11)
packages/react-core/package.jsonpackages/react-core/src/components/Page/PageGroup.tsxpackages/react-core/src/components/Page/PageSection.tsxpackages/react-core/src/components/Page/__tests__/PageGroup.test.tsxpackages/react-core/src/components/Page/__tests__/PageSection.test.tsxpackages/react-core/src/components/Page/examples/Page.mdpackages/react-core/src/components/Page/examples/PageDynamicStickySection.tsxpackages/react-docs/package.jsonpackages/react-icons/package.jsonpackages/react-styles/package.jsonpackages/react-tokens/package.json
What: Closes #12330
Additional issues:
Summary by CodeRabbit
New Features
stickyBaseandisStickyStuckproperties, enabling dynamic sticky behavior based on scroll position.Tests
Documentation
Chores