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

Add V9 Shim for V8 Checkbox #29620

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Janey2022
Copy link

Previous Behavior

New Behavior

Related Issue(s)

  • Fixes #

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 24, 2023

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.

Latest deployment of this branch, based on commit 4eeddcc:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@Janey2022 Janey2022 marked this pull request as ready for review October 25, 2023 06:01
@Janey2022 Janey2022 requested review from GeoffCoxMSFT and a team as code owners October 25, 2023 06:01
shimProps.checked = isChecked;
shimProps.onChange = onChange;

const defaultLabelRendderer = (checkboxProps?: ICheckboxProps): JSX.Element | null => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const defaultLabelRendderer = (checkboxProps?: ICheckboxProps): JSX.Element | null => {
const defaultLabelRenderer = (checkboxProps?: ICheckboxProps): JSX.Element | null => {

return onChangeV8(ev, data.checked as boolean);
});

const V9Props: Partial<CheckboxProps> = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const V9Props: Partial<CheckboxProps> = {
const v9Props: Partial<CheckboxProps> = {


labelPosition: boxSide === 'end' ? 'before' : 'after',
onChange,
} as Partial<CheckboxProps>;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} as Partial<CheckboxProps>;
};

@@ -0,0 +1,10 @@
export function getHTMLAttributes<T extends object>(props: T, allV8PropsSet: Set<string>): T {
Copy link
Member

Choose a reason for hiding this comment

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

Consider putting this in shimCheckboxProps.ts as it is only called from there. If it is useful to other shims we could move it higher in the source tree later.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it's a common function shared in other shims.

} as CheckboxProps;
};

const CHECKBOX_PROPS_V8: Set<string> = new Set([
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Avoid using things before declaring them.


return {
...inputProps, // This inputProps is specific for the input element, and the html attributes are also used here instead of props.
'aria-describedby': ariaDescribedBy,
Copy link
Member

Choose a reason for hiding this comment

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

Question: Is it duplicate to write aria-describedby here when there is the getHTMLAttributes that includes it too?

Copy link
Author

Choose a reason for hiding this comment

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

It should not be duplicated, as the "aria-describedby" is defined as ariaDescribedBy in V8, need to be translated to the origin html.

title,
name,
...V9Props,
...getHTMLAttributes(props, CHECKBOX_PROPS_V8),
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we want to spread all the v8 props on to the v9 component as the v9 component won't do anything with them.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it's mainly to get all the missed htmlattributes, and we will also delete some v8 props in getHTMLAttributes

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

Successfully merging this pull request may close these issues.

2 participants