Skip to content

Commit

Permalink
fix: console errors from highlight component and tag key prop placeme…
Browse files Browse the repository at this point in the history
…nt (#8669)

Addressing some oversights that led to browser console errors.

This PR fixes console errors related to the recently introduced
highlight component (#8643) and tag row component in the new flag
metadata panel (#8663).
  • Loading branch information
nunogois authored Nov 6, 2024
1 parent 314a4d7 commit 328fac3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 16 additions & 10 deletions frontend/src/component/common/Highlight/Highlight.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { alpha, styled } from '@mui/material';
import type { ReactNode } from 'react';
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
import { useHighlightContext } from './HighlightContext';
import type { HighlightKey } from './HighlightProvider';

Expand Down Expand Up @@ -27,17 +27,23 @@ const StyledHighlight = styled('div', {
},
}));

interface IHighlightProps {
interface IHighlightProps extends HTMLAttributes<HTMLDivElement> {
highlightKey: HighlightKey;
children: ReactNode;
}

export const Highlight = ({ highlightKey, children }: IHighlightProps) => {
const { isHighlighted } = useHighlightContext();
export const Highlight = forwardRef<HTMLDivElement, IHighlightProps>(
({ highlightKey, children, ...props }, ref) => {
const { isHighlighted } = useHighlightContext();

return (
<StyledHighlight highlighted={isHighlighted(highlightKey)}>
{children}
</StyledHighlight>
);
};
return (
<StyledHighlight
ref={ref}
highlighted={isHighlighted(highlightKey)}
{...props}
>
{children}
</StyledHighlight>
);
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ export const TagRow = ({ feature }: IFeatureOverviewSidePanelTagsProps) => {
const tagLabel = `${tag.type}:${tag.value}`;
return (
<Tooltip
key={tagLabel}
title={
tagLabel.length > 35 ? tagLabel : ''
}
arrow
>
<StyledAddedTag
key={tagLabel}
label={tagLabel}
size='small'
deleteIcon={
Expand Down

0 comments on commit 328fac3

Please sign in to comment.