Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: IconButton types do not include href #17955

Closed
2 tasks done
adamalston opened this issue Nov 1, 2024 · 0 comments · Fixed by #18283
Closed
2 tasks done

[Bug]: IconButton types do not include href #17955

adamalston opened this issue Nov 1, 2024 · 0 comments · Fixed by #18283
Assignees

Comments

@adamalston
Copy link
Contributor

adamalston commented Nov 1, 2024

Package

@carbon/react

Browser

No response

Package version

1.67.1

React version

No response

Description

The types for IconButton (IconButtonProps) do not include href. However, the types for Button (ButtonProps which use ButtonBaseProps) do include an href.

Reproduction/example

https://stackblitz.com/edit/github-azd4us?file=src%2FApp.tsx

Steps to reproduce

Paste the following code in an IDE with support for TypeScript (e.g., VS Code):

import { Button, IconButton } from '@carbon/react';
import { Information } from '@carbon/react/icons';

const Temp = () => (
  <>
    <Button
      id="help-button"
      hasIconOnly
      renderIcon={Information}
      iconDescription="Help"
      href="/help"
      target="_blank"
      rel="noreferrer"
    />
    <IconButton
      id="help-icon-button"
      label="Help"
      href="/help"
      target="_blank"
      rel="noreferrer"
    >
      <Information />
    </IconButton>
  </>
);

See the following error:

Type '{ children: Element; id: string; label: string; href: string; target: string; rel: string; }' is not assignable to type 'IntrinsicAttributes & IconButtonProps & RefAttributes<unknown>'.
  Property 'href' does not exist on type 'IntrinsicAttributes & IconButtonProps & RefAttributes<unknown>'. Did you mean 'ref'?

Button accepts href. IconButton does not. They both should.

Suggested Severity

Severity 4 = Unrelated to a user task, has a workaround or does not need a workaround.

Application/PAL

DataPower

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants