diff --git a/src/internal/utils/node-belongs.ts b/src/internal/utils/node-belongs.ts index bdbc944c1c..a45c731819 100644 --- a/src/internal/utils/node-belongs.ts +++ b/src/internal/utils/node-belongs.ts @@ -15,7 +15,10 @@ export function nodeBelongs(container: Node | null, target: Node | EventTarget | if (!(target instanceof Node)) { return false; } - const portal = findUpUntil(target as HTMLElement, node => !!node.dataset.awsuiReferrerId); + const portal = findUpUntil( + target as HTMLElement, + node => node instanceof HTMLElement && !!node.dataset.awsuiReferrerId + ); const referrer = portal instanceof HTMLElement ? document.getElementById(portal.dataset.awsuiReferrerId ?? '') : null; return referrer ? nodeContains(container, referrer) : nodeContains(container, target); } diff --git a/src/mixed-line-bar-chart/__tests__/mixed-chart.test.tsx b/src/mixed-line-bar-chart/__tests__/mixed-chart.test.tsx index 555dbb94de..bfb3474fe7 100644 --- a/src/mixed-line-bar-chart/__tests__/mixed-chart.test.tsx +++ b/src/mixed-line-bar-chart/__tests__/mixed-chart.test.tsx @@ -772,7 +772,7 @@ describe('Filter', () => { describe('Dropdown', () => { const openDropdown = (wrapper: MixedLineBarChartWrapper) => { - wrapper.findDefaultFilter()?.openDropdown(); + wrapper.findDefaultFilter()!.openDropdown(); return wrapper.findDefaultFilter()!.findDropdown()!; }; @@ -804,6 +804,17 @@ describe('Filter', () => { expect(dropdownWrapper.findSelectedOptions()).toHaveLength(1); expect(dropdownWrapper.findSelectedOptions()[0].getElement()).toHaveTextContent(defaultData[1].title); }); + + test('allows filtering segments', () => { + const { wrapper } = renderMixedChart(); + + expect(wrapper.findSeries()).toHaveLength(2); + + wrapper.findDefaultFilter()!.openDropdown(); + wrapper.findDefaultFilter()!.selectOption(1); + wrapper.findDefaultFilter()!.closeDropdown(); + expect(wrapper.findSeries()).toHaveLength(1); + }); }); });