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

🙄 close #10932 omit disabled prop when not defined #10937

Merged
merged 1 commit into from
Sep 16, 2023

Conversation

bluebill1049
Copy link
Member

@bluebill1049 bluebill1049 commented Sep 16, 2023

fix #10932

@codesandbox
Copy link

codesandbox bot commented Sep 16, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@github-actions
Copy link
Contributor

Size Change: +27 B (0%)

Total Size: 19.9 kB

Filename Size Change
dist/index.cjs.js 9.92 kB +15 B (0%)
dist/index.umd.js 10 kB +12 B (0%)

compressed-size-action

@bluebill1049 bluebill1049 changed the title close #10932 omit disabled prop when not defined 🙄 close #10932 omit disabled prop when not defined Sep 16, 2023
@bluebill1049 bluebill1049 merged commit 5fe5614 into master Sep 16, 2023
7 checks passed
@bluebill1049 bluebill1049 deleted the close-#10932 branch September 16, 2023 12:03
@Pumpuli
Copy link

Pumpuli commented Oct 12, 2023

With the addition of the "disable whole form" feature, it's now technically possible to receive { disabled: undefined } again.

The change makes this situation possible:

const { control } = useForm({ disabled: false });

return <Controller
  // No `disabled` prop given here
  control={control}
  render={({ field }) => {
    // `field.disabled` is `undefined`
  }}
/>;

Maybe this is not critical, since it can only happen when field.disabled is supposed to be false (in other words, that undefined is never going to override anything that's supposed to be truthy).

An easy fix would be to use nullish coalescing operator here:

? { disabled: formState.disabled || disabled }

@bluebill1049
Copy link
Member Author

With the addition of the "disable whole form" feature, it's now technically possible to receive { disabled: undefined } again.

The change makes this situation possible:

const { control } = useForm({ disabled: false });

return <Controller
  // No `disabled` prop given here
  control={control}
  render={({ field }) => {
    // `field.disabled` is `undefined`
  }}
/>;

Maybe this is not critical, since it can only happen when field.disabled is supposed to be false (in other words, that undefined is never going to override anything that's supposed to be truthy).

An easy fix would be to use nullish coalescing operator here:

? { disabled: formState.disabled || disabled }

Feel free to send a PR.

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.

issue: breaking change with controller disabled feature
2 participants