-
Notifications
You must be signed in to change notification settings - Fork 140
fix: panel styles and classNames not working #409
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
Changes from 1 commit
a9aba53
ecd38af
a5d71b7
d57c865
8372d77
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 |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => { | |
| openMotion, | ||
| expandIcon, | ||
| classNames: collapseClassNames, | ||
| styles, | ||
| styles: collapseStyles, | ||
| } = props; | ||
|
|
||
| return items.map((item, index) => { | ||
|
|
@@ -33,6 +33,8 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => { | |
| collapsible: rawCollapsible, | ||
| onItemClick: rawOnItemClick, | ||
| destroyOnHidden: rawDestroyOnHidden, | ||
| classNames, | ||
| styles, | ||
| ...restProps | ||
| } = item; | ||
|
|
||
|
|
@@ -60,8 +62,8 @@ const convertItemsToNodes = (items: ItemType[], props: Props) => { | |
| return ( | ||
| <CollapsePanel | ||
| {...restProps} | ||
| classNames={collapseClassNames} | ||
| styles={styles} | ||
| classNames={classNames || collapseClassNames} | ||
|
Member
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. 不应该是替代关系,而是合并关系
Member
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. 另外也需要 test case
Contributor
Author
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. 好的,重新提交了,再看看 |
||
| styles={styles || collapseStyles} | ||
| prefixCls={prefixCls} | ||
| key={key} | ||
| panelKey={key} | ||
|
|
||
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.
Renaming
stylestocollapseStylesis a good step to avoid naming collisions. However, this fix for panel-specific styles and classNames appears to be incomplete because it only applies to panels defined via theitemsprop.The
getNewChildfunction (which handlesPanelcomponents passed aschildren, starting on line 88) has not been updated. It still passes theCollapsecomponent'sstylesandclassNamesto eachCollapsePanel, ignoring the props on thePanelitself.To ensure consistent behavior, I recommend applying a similar fix to the
getNewChildfunction. This would involve:classNamesandstylesfromchild.props.childClassNames || collapseClassNamesandchildStyles || collapseStylesto the cloned element.This will make the fix comprehensive, even though
getNewChildis deprecated.