fix: replace button with div in IdBadge to prevent hydration issues (backport) (#6602)

This commit is contained in:
Dhruwang Jariwala
2025-09-25 19:12:29 +05:30
committed by GitHub
parent 0eddeb46c1
commit 4112722a88
2 changed files with 4 additions and 4 deletions

View File

@@ -59,8 +59,8 @@ export const BadgeContent: React.FC<BadgeContentProps> = ({
};
const content = (
<button
type="button"
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/prefer-tag-over-role, jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div
role={isCopyEnabled ? "button" : undefined}
className={getButtonClasses()}
onClick={handleCopy}
@@ -69,7 +69,7 @@ export const BadgeContent: React.FC<BadgeContentProps> = ({
onMouseLeave={isCopyEnabled ? () => setIsHovered(false) : undefined}>
<span>{id}</span>
{renderIcon()}
</button>
</div>
);
const getTooltipContent = () => {

View File

@@ -96,7 +96,7 @@ describe("IdBadge", () => {
test("removes interactive elements when copy is disabled", () => {
const { container } = render(<IdBadge id="1734" copyDisabled={true} />);
const badge = container.querySelector("button");
const badge = container.querySelector("div");
// Should not have cursor-pointer class
expect(badge).not.toHaveClass("cursor-pointer");