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]: FormGroup lost disabled attribute in Carbon 11 #17057

Closed
2 tasks done
wkeese opened this issue Jul 29, 2024 · 1 comment · Fixed by #17058
Closed
2 tasks done

[Bug]: FormGroup lost disabled attribute in Carbon 11 #17057

wkeese opened this issue Jul 29, 2024 · 1 comment · Fixed by #17058

Comments

@wkeese
Copy link
Contributor

wkeese commented Jul 29, 2024

Package

@carbon/react

Browser

Chrome

Package version

1.62.1

React version

18

Description

In Carbon 10, FormGroup had a disabled attribute. In Carbon 11 (@carbon/react V1), it does not.

Since fieldset has a disabled attribute, and FormGroup is just a fieldset, then FormGroup should have a disabled attribute too.

Reproduction/example

https://stackblitz.com/edit/vitejs-vite-pwka1x?file=package.json

Steps to reproduce

I didn't have much luck reproducing this on Stackblitz. If there's a working example with Typescript and Carbon then I'd be happy to modify it to reproduce the error.

Suggested Severity

None

Application/PAL

IKC

Code of Conduct

wkeese added a commit to wkeese/carbon that referenced this issue Jul 29, 2024
@riddhybansal riddhybansal moved this to ⏱ Backlog in Design System Jul 29, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 30, 2024
* fix: add disabled attribute back to FormGroup

Fixes #17057.

* chore: update snapshot to fix test
@github-project-automation github-project-automation bot moved this from ⏱ Backlog to ✅ Done in Design System Jul 30, 2024
@wkeese
Copy link
Contributor Author

wkeese commented Jul 31, 2024

FYI, some research on the underlying problem:

Carbon 10 had the correct declaration (provided through @types/carbon-components-react):

export interface FormGroupProps extends React.FieldsetHTMLAttributes<HTMLFieldSetElement> {

whereas Carbon 11 is essentially doing

export interface FormGroupProps extends React.HTMLAttributes<HTMLFieldSetElement> {

So the difference is FieldsetHTMLAttributes vs HTMLAttributes.

One might think that HTMLAttributes<T> returns all the attributes of T, but it actually only returns a hardcoded list of attributes that apply to all HTML elements.

ReactAttr<HTMLFieldSet> --> HTMLAttributes<HTMLFieldSet> --> DOMAttributes<HTMLFieldSet> —> hardcoded list of attributes.

So I guess extending React.FieldsetHTMLAttributes<HTMLFieldSetElement> would have been a better strategy to fix this. It's what Carbon 11 does for TextInput:

export interface TextInputProps
  extends Omit<
    React.InputHTMLAttributes<HTMLInputElement>,
    ExcludedAttributes
  > {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants