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

(web-components) Use ElementInternals for Checkbox component #31468

Merged

Conversation

radium-v
Copy link
Contributor

Previous Behavior

Currently, form-associated custom elements use the FormAssociated class mixin. This mixin is heavy and duplicative, being copied wholesale for every component which utilizes it. While FormAssociated includes minimal support for ElementInternals, the implementation isn't fully baked.

New Behavior

Improvements:

  • Switches the <fluent-checkbox> custom element to use ElementInternals by default. An optional polyfill may be added in the near future, as more components transition to use ElementInternals.
  • Adds a <fluent-field> custom element to handle layout and label management. Most elements have a heavy template which includes a slotted <label> due to cross-root ARIA not existing yet. The <fluent-field> component allows for better composition, and makes each individual input-style component lighter and more performant.

@fabricteam
Copy link
Collaborator

fabricteam commented May 23, 2024

📊 Bundle size report

✅ No changes found

Copy link

codesandbox-ci bot commented May 23, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@radium-v radium-v force-pushed the users/radium-v/web-components-v3-checkbox branch from 58c0852 to 1e65155 Compare May 23, 2024 22:29
@radium-v radium-v force-pushed the users/radium-v/web-components-v3-checkbox branch from 1e65155 to fb2db45 Compare May 30, 2024 02:03
@radium-v radium-v marked this pull request as ready for review May 30, 2024 02:05
@radium-v radium-v requested a review from a team as a code owner May 30, 2024 02:05
@radium-v radium-v force-pushed the users/radium-v/web-components-v3-checkbox branch from fb2db45 to 84a58cf Compare May 30, 2024 16:40
Copy link
Contributor

@davatron5000 davatron5000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 🙌 I do have a general question/thought. I know the objective was to covert this to elementInternals but it seems like the amount of script for a fluent-checkbox has increased ~4x.

I don't think it's a blocker but any thoughts there? Maybe there's a future abstraction like a FASTFormAssociatedElement base class that pulls out of some the boilerplate?

packages/web-components/src/checkbox/checkbox.ts Outdated Show resolved Hide resolved
packages/web-components/src/field/field.template.ts Outdated Show resolved Hide resolved
packages/web-components/src/field/field.styles.ts Outdated Show resolved Hide resolved
packages/web-components/src/field/field.stories.ts Outdated Show resolved Hide resolved
@radium-v
Copy link
Contributor Author

radium-v commented Jun 1, 2024

Great work! 🙌 I do have a general question/thought. I know the objective was to covert this to elementInternals but it seems like the amount of script for a fluent-checkbox has increased ~4x.

I don't think it's a blocker but any thoughts there? Maybe there's a future abstraction like a FASTFormAssociatedElement base class that pulls out of some the boilerplate?

@davatron5000 It's an optical illusion 🌫️

The original Checkbox class extended from the CheckableFormAssociated mixin class:

export function CheckableFormAssociated<T extends ConstructableFormAssociated>(BaseCtor: T): T {

The CheckableFormAssociated function extends the FormAssociated mixin class, so it's fair to say that almost everything present in that file was being added to the class at build time.

@radium-v radium-v force-pushed the users/radium-v/web-components-v3-checkbox branch from 84a58cf to 8a660aa Compare June 6, 2024 03:25
@radium-v radium-v force-pushed the users/radium-v/web-components-v3-checkbox branch from e333255 to 8fb2887 Compare June 6, 2024 17:52
@radium-v radium-v enabled auto-merge (squash) June 6, 2024 17:54
@radium-v radium-v merged commit afa7744 into microsoft:master Jun 6, 2024
16 of 18 checks passed
@radium-v radium-v deleted the users/radium-v/web-components-v3-checkbox branch June 6, 2024 18:07
miroslavstastny pushed a commit to miroslavstastny/fluentui that referenced this pull request Jun 14, 2024
…ft#31468)

- Adds the `<fluent-field>` component
- Fixes focus delegation in `<fluent-text-input>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants