mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
grafana-ui: Improve PartialHighlighter error handling (#39685)
* Improve PartialHighlighter error handling
This commit is contained in:
parent
fffcee7c1f
commit
05bb451a1d
@ -45,4 +45,11 @@ describe('PartialHighlighter component', () => {
|
|||||||
assertPart(main.childAt(1), false, ' ipsum dolor sit ');
|
assertPart(main.childAt(1), false, ' ipsum dolor sit ');
|
||||||
assertPart(main.childAt(2), true, 'amet');
|
assertPart(main.childAt(2), true, 'amet');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns null if highlightParts is empty', () => {
|
||||||
|
const component = mount(
|
||||||
|
<PartialHighlighter text="Lorem ipsum dolor sit amet" highlightClassName="highlight" highlightParts={[]} />
|
||||||
|
);
|
||||||
|
expect(component.html()).toBe(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -29,7 +29,7 @@ function getStartIndices(parts: HighlightPart[], length: number): number[] {
|
|||||||
export const PartialHighlighter: React.FC<Props> = (props: Props) => {
|
export const PartialHighlighter: React.FC<Props> = (props: Props) => {
|
||||||
let { highlightParts, text, highlightClassName } = props;
|
let { highlightParts, text, highlightClassName } = props;
|
||||||
|
|
||||||
if (!highlightParts) {
|
if (!highlightParts?.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user