Skip to content

Commit

Permalink
fix(react): fix CompositePanel
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Oct 8, 2021
1 parent 06f1299 commit f64a5aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/react/src/panels/CompositePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ICompositePanelProps {
defaultPinning?: boolean
defaultActiveKey?: number
activeKey?: number | string
onChange?: (activeKey: number) => void
onChange?: (activeKey: number | string) => void
}
export interface ICompositePanelItemProps {
shape?: 'tab' | 'button' | 'link'
Expand All @@ -27,9 +27,9 @@ const parseItems = (
children: React.ReactNode
): React.PropsWithChildren<ICompositePanelItemProps>[] => {
const items = []
React.Children.forEach(children, (child) => {
React.Children.forEach(children, (child, index) => {
if (child?.['type'] === CompositePanel.Item) {
items.push({ key: child['key'], ...child['props'] })
items.push({ key: child['key'] ?? index, ...child['props'] })
}
})
return items
Expand Down Expand Up @@ -161,7 +161,7 @@ export const CompositePanel: React.FC<ICompositePanelProps> & {
setActiveKey(index)
}
item.onClick?.(e)
props.onChange?.(index)
props.onChange?.(item.key ?? index)
}}
>
{takeTab()}
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/panels/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
display: flex;
flex-direction: column;
background-color: var(--dn-composite-panel-tabs-bg-color);
border-right: 1px solid var(--dn-panel-border-color);
z-index: 2;
position: relative;

Expand Down Expand Up @@ -99,7 +98,7 @@
left: 0;
display: block;
content: '';
width: 2px;
width: 3px;
height: 100%;
background-color: var(--dn-composite-panel-tabs-hover-color);
}
Expand Down Expand Up @@ -182,7 +181,7 @@

.@{prefix-cls}-composite-panel-tabs-pane.active:after {
left: auto;
right: -1px;
right: 0px;
}

.@{prefix-cls}-composite-panel-tabs-content.pinning {
Expand Down

0 comments on commit f64a5aa

Please sign in to comment.