Skip to content

Commit

Permalink
Remove OverridableComponent from Chips.Removable. This component shou…
Browse files Browse the repository at this point in the history
…ld always be a button, and it is not currently used in any other way.

The reason for making this change now, is that we put type="button" on the Chip.Removable to prevent a submit event when the chip is clicked inside a form.
  • Loading branch information
it-vegard committed Aug 3, 2023
1 parent 59f1a6d commit a3ba0fe
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions @navikt/core/react/src/chips/Removable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { XMarkIcon } from "@navikt/aksel-icons";
import cl from "clsx";
import React, { forwardRef } from "react";
import { OverridableComponent } from "../util/OverridableComponent";

export interface RemovableChipsProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
Expand All @@ -22,16 +21,15 @@ export interface RemovableChipsProps
onDelete?: () => void;
}

export const RemovableChips: OverridableComponent<
RemovableChipsProps,
HTMLButtonElement
> = forwardRef(
export const RemovableChips = forwardRef<
HTMLButtonElement,
RemovableChipsProps
>(
(
{
className,
children,
variant = "action",
as: Component = "button",
removeLabel = "slett",
onDelete,
type = "button",
Expand All @@ -40,7 +38,7 @@ export const RemovableChips: OverridableComponent<
ref
) => {
return (
<Component
<button
{...rest}
ref={ref}
type={type}
Expand All @@ -59,7 +57,7 @@ export const RemovableChips: OverridableComponent<
<span className="navds-chips__removable-icon">
<XMarkIcon aria-hidden />
</span>
</Component>
</button>
);
}
);
Expand Down

0 comments on commit a3ba0fe

Please sign in to comment.