Skip to content

Commit

Permalink
chore: get highlightedNode from itemWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunory committed Nov 14, 2023
1 parent 44bef42 commit 573a05e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/CompositeBar/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@ export const Item: React.FC<ItemInnerProps> = (props) => {
};

const makeNode = ({icon: iconEl, title: titleEl}: MakeItemParams) => {
const iconNode = makeIconNode(iconEl);

if (bringForward) {
highlightedNode = iconNode;
}

const createdNode = (
<React.Fragment>
<div
Expand Down Expand Up @@ -191,7 +185,7 @@ export const Item: React.FC<ItemInnerProps> = (props) => {
}}
>
<div className={b('icon-place')} ref={highlightedRef}>
{iconNode}
{makeIconNode(iconEl)}
</div>

<div
Expand Down Expand Up @@ -237,8 +231,16 @@ export const Item: React.FC<ItemInnerProps> = (props) => {

if (typeof item.itemWrapper === 'function') {
node = item.itemWrapper(params, makeNode, opts) as React.ReactElement;
highlightedNode =
bringForward &&
(item.itemWrapper(
params,
({icon: iconEl}) => makeIconNode(iconEl),
opts,
) as React.ReactElement);
} else {
node = makeNode(params);
highlightedNode = bringForward && makeIconNode(iconNode);
}

return (
Expand Down

0 comments on commit 573a05e

Please sign in to comment.