Skip to content

feat(react-textarea): add useTextareaBase_unstable hook#35822

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

feat(react-textarea): add useTextareaBase_unstable hook#35822
dmytrokirpa wants to merge 2 commits intomasterfrom
feat/react-textarea-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

Summary

  • Adds useTextareaBase_unstable hook to react-textarea that extracts pure component logic without design props
  • Adds TextareaBaseProps type omitting appearance and size (design-related props); resize is kept as it is a structural/behavioral prop controlling how users can resize the textarea
  • Adds TextareaBaseState type omitting appearance and size
  • Refactors useTextarea_unstable to call useTextareaBase_unstable internally
  • Exports new types and hook from package index.ts

What base hooks include

The base hook preserves:

  • Slot structure (root span wrapper and textarea element slots)
  • resize structural prop (controls textarea resize behavior)
  • Controlled/uncontrolled value state via useControllableState
  • onChange callback with typed data
  • Field integration via useFieldControlProps_unstable

The base hook excludes:

  • appearance prop (outline/filled-darker/filled-lighter variants - design concern)
  • size prop (small/medium/large - design concern)

Test plan

  • Verify useTextareaBase_unstable can be imported from @fluentui/react-textarea
  • Verify TextareaBaseProps and TextareaBaseState types are exported
  • Verify existing useTextarea_unstable behavior is unchanged
  • Verify controlled and uncontrolled textarea value management works via the base hook
  • Verify the deprecated appearance warning still fires in the styled hook

🤖 Generated with Claude Code

dmytrokirpa and others added 2 commits March 5, 2026 12:06
Adds a base state hook for Textarea component that extracts pure component
logic (slot structure, controlled/uncontrolled value state) without
design-related props (appearance, size).

- Add TextareaBaseProps type omitting appearance and size (design props)
- Add TextareaBaseState type omitting appearance and size
- Add useTextareaBase_unstable hook that handles:
  - Slot setup (root and textarea slots)
  - Controlled/uncontrolled value state via useControllableState
  - onChange callback management
  - Field integration via useFieldControlProps_unstable
  - resize structural prop (controls how users can resize the textarea)
- Refactor useTextarea_unstable to call useTextareaBase_unstable internally
- Export new types and hook from package index.ts

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

github-actions bot commented Mar 5, 2026

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.292 MB
323.107 kB
1.292 MB
323.114 kB
40 B
7 B
react-textarea
Textarea
24.628 kB
8.954 kB
24.668 kB
8.969 kB
40 B
15 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
70.397 kB
19.96 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
236.537 kB
68.697 kB
react-components
react-components: FluentProvider & webLightTheme
43.612 kB
14.022 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-timepicker-compat
TimePicker
108.174 kB
35.695 kB
🤖 This report was generated against ace36179073ac4600a3635304a0941bd7dcda21d

@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.default.chromium_1.png 403 Changed
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 1236 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium.png 495 Changed
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 1107 Changed
vr-tests-react-components/Field 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Field.Textarea+horizontal.default.chromium.png 2696 Changed
vr-tests-react-components/Field.Textarea.default.chromium.png 3543 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 605 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 514 Changed
vr-tests-react-components/TagPicker 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png 677 Changed

There were 2 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