-
-
Notifications
You must be signed in to change notification settings - Fork 451
fix: preserve default className when className is null or undefined #599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -373,27 +373,49 @@ const UncontrolledTabs = (props) => { | |||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||
| children, // unused | ||||||||||||||||||||||||||||||||||||||||||
| className, | ||||||||||||||||||||||||||||||||||||||||||
| disabledTabClassName, // unused | ||||||||||||||||||||||||||||||||||||||||||
| className: propClassName, | ||||||||||||||||||||||||||||||||||||||||||
| domRef, | ||||||||||||||||||||||||||||||||||||||||||
| focus, // unused | ||||||||||||||||||||||||||||||||||||||||||
| forceRenderTabPanel, // unused | ||||||||||||||||||||||||||||||||||||||||||
| onSelect, // unused | ||||||||||||||||||||||||||||||||||||||||||
| selectedIndex, // unused | ||||||||||||||||||||||||||||||||||||||||||
| selectedTabClassName, // unused | ||||||||||||||||||||||||||||||||||||||||||
| selectedTabPanelClassName, // unused | ||||||||||||||||||||||||||||||||||||||||||
| environment, // unused | ||||||||||||||||||||||||||||||||||||||||||
| disableUpDownKeys, // unused | ||||||||||||||||||||||||||||||||||||||||||
| disableLeftRightKeys, // unused | ||||||||||||||||||||||||||||||||||||||||||
| ...attributes | ||||||||||||||||||||||||||||||||||||||||||
| } = { | ||||||||||||||||||||||||||||||||||||||||||
| ...defaultProps, | ||||||||||||||||||||||||||||||||||||||||||
| ...props, | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
| children, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| disabledTabClassName, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| focus, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| forceRenderTabPanel, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| onSelect, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| selectedIndex, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| selectedTabClassName, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| selectedTabPanelClassName, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| environment, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| disableUpDownKeys, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| disableLeftRightKeys, // unused here | ||||||||||||||||||||||||||||||||||||||||||
| ...restProps | ||||||||||||||||||||||||||||||||||||||||||
| } = props; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // Only pass valid DOM attributes and data- attributes | ||||||||||||||||||||||||||||||||||||||||||
| const domAttributes = {}; | ||||||||||||||||||||||||||||||||||||||||||
| Object.keys(restProps).forEach((key) => { | ||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||
| key.startsWith('data-') || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'id' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'style' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'title' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'role' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'tabIndex' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'aria-label' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'aria-labelledby' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'aria-describedby' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'aria-controls' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'aria-selected' || | ||||||||||||||||||||||||||||||||||||||||||
| key === 'aria-disabled' | ||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||
| domAttributes[key] = restProps[key]; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+392
to
+411
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const className = | ||||||||||||||||||||||||||||||||||||||||||
| propClassName == null ? defaultProps.className : propClassName; | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+413
to
+414
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||
| {...attributes} | ||||||||||||||||||||||||||||||||||||||||||
| {...domAttributes} | ||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| className={cx(className)} | ||||||||||||||||||||||||||||||||||||||||||
| onClick={handleClick} | ||||||||||||||||||||||||||||||||||||||||||
| onKeyDown={handleKeyDown} | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.