diff --git a/site/source/design-system/buttons/Button.tsx b/site/source/design-system/buttons/Button.tsx index de5121351..6847510c0 100644 --- a/site/source/design-system/buttons/Button.tsx +++ b/site/source/design-system/buttons/Button.tsx @@ -5,7 +5,7 @@ import { GenericButtonOrNavLinkProps, useButtonOrLink, } from '@/design-system/typography/link' -import { wrapperDebounceEvents } from '@/utils' +import { omit, wrapperDebounceEvents } from '@/utils' import { FocusStyle } from '../global-style' @@ -41,13 +41,17 @@ export const Button = forwardRef(function Button( forwardedRef ) - // @ts-ignore - delete buttonOrLinkProps.isDisabled // Remove isDisabled from props casue it's not a valid HTML attribute + // Omit isDisabled and openInSameWindow from props casue it's not a valid HTML attribute + const props = omit( + buttonOrLinkProps as Record, + 'isDisabled', + 'openInSameWindow' + ) return ( (obj: T, key: K): Omit { - const { [key]: _ignore, ...returnObject } = obj +/** + * Omits the given keys from the object + * @param obj + * @param keys + * @example omit({ a: 1, b: 2, c: 3 }, 'a', 'c') // { b: 2 } + */ +export function omit( + obj: T, + ...keys: K[] +): Omit { + const ret = keys.reduce( + (acc, key) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { [key]: _, ...rest } = acc as T - return returnObject + return rest + }, + obj as Omit + ) + + return ret } /**