Skip to content

refactor: convert ToggleButton and ToggleButtonGroup to functional components#6913

Merged
tujoworker merged 17 commits intov11from
refactor/toggle-button-to-functional
Apr 5, 2026
Merged

refactor: convert ToggleButton and ToggleButtonGroup to functional components#6913
tujoworker merged 17 commits intov11from
refactor/toggle-button-to-functional

Conversation

@langz
Copy link
Copy Markdown
Contributor

@langz langz commented Mar 4, 2026

No description provided.

@langz langz changed the title refactor: convert ToggleButton and ToggleButtonGroup to functional co… refactor: convert ToggleButton and ToggleButtonGroup to functional components Mar 4, 2026
@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Mar 4, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Branch Preview URL (stable):
https://refactor-toggle-button-to-fu.eufemia-e25.pages.dev

https://refactor-toggle-button-to-fu.eufemia-e25.pages.dev

Deployment URL (unique):
https://14abbb6a.eufemia-e25.pages.dev

https://14abbb6a.eufemia-e25.pages.dev

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 4, 2026

commit: a96bcd7

@langz langz requested a review from tujoworker March 6, 2026 12:49
@langz langz force-pushed the refactor/toggle-button-to-functional branch 7 times, most recently from 4a2cc22 to 1e7bda2 Compare March 16, 2026 09:12
@langz langz force-pushed the refactor/toggle-button-to-functional branch 5 times, most recently from 7a29a0f to 7582a09 Compare March 19, 2026 08:38
Comment thread packages/dnb-eufemia/src/components/toggle-button/ToggleButton.tsx Outdated
Comment thread packages/dnb-eufemia/src/components/toggle-button/ToggleButton.tsx Outdated
Comment thread packages/dnb-eufemia/src/components/toggle-button/ToggleButton.tsx Outdated
Comment thread packages/dnb-eufemia/src/components/toggle-button/ToggleButton.tsx Outdated
@langz langz force-pushed the refactor/toggle-button-to-functional branch 2 times, most recently from 9b1829b to b771d1e Compare March 26, 2026 12:55
langz added 10 commits April 5, 2026 06:34
H3: Use ownProps.value ?? '' in callOnChange to match the class component
    behavior where this.props.value had a default of '' from defaultProps.
M3: Copy the values array before push/splice to avoid direct state mutation.
The original class component extended React.PureComponent which provides
shallow prop comparison. React.memo is the functional equivalent.
…tContext

- ToggleButton: add ownPropsRef, groupContextRef, checkedRef; update
  callOnChange and onClickHandler to use refs instead of closure values,
  removing ownProps/groupContext/checked from dependency arrays
- ToggleButtonGroup: add ownPropsRef, valuesRef; update onChangeHandler
  to use refs; extract setContext into a stable useCallback
langz and others added 7 commits April 5, 2026 06:34
…Button

Explains why onlyMergeExistingProps: true is needed to prevent
context props from leaking to DOM attributes.
…tonGroup

- ToggleButton: restore proper onChange type (ToggleButtonChangeEvent) instead of generic (...args: unknown[]) => void
- ToggleButtonGroupContext: use specific value type instead of unknown in onChange
- ToggleButtonGroup: add back ToggleButtonGroupChangeEvent type and use it for onChange prop
@tujoworker tujoworker force-pushed the refactor/toggle-button-to-functional branch from b771d1e to a96bcd7 Compare April 5, 2026 04:44
@tujoworker tujoworker merged commit 37e45a2 into v11 Apr 5, 2026
11 checks passed
@tujoworker tujoworker deleted the refactor/toggle-button-to-functional branch April 5, 2026 05:54
@tujoworker
Copy link
Copy Markdown
Member

Did test things manually. Worked as expected/before.

tujoworker added a commit that referenced this pull request Apr 5, 2026
…mponents (#6913)

Co-authored-by: Tobias Høegh <tobias@tujo.no>
tujoworker added a commit that referenced this pull request Apr 5, 2026
…mponents (#6913)

Co-authored-by: Tobias Høegh <tobias@tujo.no>
tujoworker added a commit that referenced this pull request Apr 5, 2026
…mponents (#6913)

Co-authored-by: Tobias Høegh <tobias@tujo.no>
tujoworker added a commit that referenced this pull request Apr 6, 2026
…mponents (#6913)

Co-authored-by: Tobias Høegh <tobias@tujo.no>
tujoworker added a commit that referenced this pull request Apr 6, 2026
…mponents (#6913)

Co-authored-by: Tobias Høegh <tobias@tujo.no>
tujoworker added a commit that referenced this pull request Apr 6, 2026
…mponents (#6913)

Co-authored-by: Tobias Høegh <tobias@tujo.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants