diff --git a/packages/core/src/components/icon/icon.tsx b/packages/core/src/components/icon/icon.tsx index d74147797c..2d708d2668 100644 --- a/packages/core/src/components/icon/icon.tsx +++ b/packages/core/src/components/icon/icon.tsx @@ -171,7 +171,7 @@ export const Icon: IconComponent = React.forwardRef(function : size === IconSize.LARGE ? Classes.ICON_LARGE : undefined; - return React.createElement(tagName!, { + return React.createElement(tagName || "span", { "aria-hidden": title ? undefined : true, ...removeNonHTMLProps(htmlProps), className: classNames( diff --git a/packages/core/test/icon/iconTests.tsx b/packages/core/test/icon/iconTests.tsx index 211776bc10..613da644ec 100644 --- a/packages/core/test/icon/iconTests.tsx +++ b/packages/core/test/icon/iconTests.tsx @@ -132,7 +132,8 @@ describe("", () => { it("allows specifying the root element as when tagName={null}", () => { const handleClick: React.MouseEventHandler = () => undefined; - mount( icon="add" onClick={handleClick} tagName={null} />); + const wrapper = mount( icon="add" onClick={handleClick} tagName={null} />); + assert.isFalse(wrapper.find("span").exists()); }); /** Asserts that rendered icon has an SVG path. */