Skip to content

feat(react-link): add useLinkBase_unstable hook#35816

Draft
dmytrokirpa wants to merge 2 commits intomasterfrom
feat/react-link-base-hooks
Draft

feat(react-link): add useLinkBase_unstable hook#35816
dmytrokirpa wants to merge 2 commits intomasterfrom
feat/react-link-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

Summary

  • Adds LinkBaseProps type derived from LinkProps by omitting design prop (appearance)
  • Adds LinkBaseState type derived from LinkState by omitting design props (appearance, backgroundAppearance)
  • Adds useLinkBase_unstable hook that handles:
    • Disabled/disabledFocusable behavior: prevents click/keydown when disabled, sets aria-disabled, manages disabled attribute for button elements
    • Keyboard handling: Enter/Space key support for anchor and span elements (via useLinkState_unstable)
    • ARIA: role="link" for disabled anchors, tabIndex management
    • Element type inference: auto-selects <a> or <button> based on href prop or as prop
    • Inline text context from useLinkContext
  • Refactors useLink_unstable to call useLinkBase_unstable and spread its results, then add appearance and backgroundAppearance
  • Note: Link uses the ARIAButton-like pattern (similar to Button) where the element type is determined at runtime
  • Exports new types and hook from packages/react-components/react-link/library/src/index.ts

What base hooks do

Base hooks extract pure component logic — ARIA, keyboard handling, slot structure — WITHOUT styling, design props, or default slot implementations. This allows consumers to build custom-styled variants without taking on the full FluentUI design system.

Test plan

  • Verify TypeScript types compile correctly
  • Verify useLink_unstable still works as before (behavior unchanged)
  • Verify useLinkBase_unstable handles disabled/disabledFocusable correctly
  • Verify useLinkBase_unstable correctly infers element type from href prop
  • Verify new exports are available from package index

🤖 Generated with Claude Code

dmytrokirpa and others added 2 commits March 5, 2026 11:56
Adds LinkBaseProps, LinkBaseState types and useLinkBase_unstable hook to the react-link package.
The base hook handles ARIA attributes, keyboard handling (via useLinkState_unstable), disabled/disabledFocusable
behavior, and slot structure without design-specific props (appearance, backgroundAppearance).
The styled useLink_unstable hook is refactored to call the base hook and spread its results.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dmytrokirpa dmytrokirpa changed the base branch from experimental/component-base-hooks to master March 5, 2026 10:57
@dmytrokirpa dmytrokirpa force-pushed the feat/react-link-base-hooks branch from e18e06e to 0873178 Compare March 5, 2026 10:57
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Pull request demo site: URL

@@ -0,0 +1,7 @@
{
Copy link

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/CalendarCompat 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 1107 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium_1.png 403 Changed
vr-tests-react-components/CalendarCompat.multiDayView - RTL.default.chromium.png 495 Changed
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 1236 Changed
vr-tests-react-components/Charts-DonutChart 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default - RTL.submenus open.chromium.png 404 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default.submenus open.chromium.png 606 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 608 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 125 Changed
vr-tests-react-components/TagPicker 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png 658 Changed
vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png 1319 Changed

There were 3 duplicate changes discarded. Check the build logs for more information.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant