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 disable property to input and select field #34

Merged
merged 2 commits into from
Mar 15, 2024
Merged

Conversation

luizakp
Copy link
Contributor

@luizakp luizakp commented Mar 14, 2024

No description provided.

@luizakp luizakp requested a review from ribeirojose March 14, 2024 16:40
@@ -56,6 +56,7 @@ export const InputField = withConditional<InputFieldProps>(
<Input
placeholder={field.placeholder}
{...formField}
disabled={field.disabled ? (field.disabled as boolean) : false}
Copy link
Contributor

Choose a reason for hiding this comment

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

is it not boolean by default in the type? 😬 it should be disabled?: boolean. this could be written as field.disabled ?? false

Copy link
Contributor Author

@luizakp luizakp Mar 14, 2024

Choose a reason for hiding this comment

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

right now

disabled?: boolean | ((data: FieldValues) => boolean);

and with this I get

Type 'boolean | ((data: FieldValues) => boolean)' is not assignable to type 'boolean | undefined'.
  Type '(data: FieldValues) => boolean' is not assignable to type 'boolean | undefined'.ts(2322)

Saw we do this on SwitchField

    const disabled =
      typeof field.disabled === "function"
        ? field.disabled(form.getValues())
        : field.disabled;

Copy link
Contributor

@ribeirojose ribeirojose left a comment

Choose a reason for hiding this comment

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

lgtm just left a small comment

@luizakp luizakp merged commit 0a93af6 into main Mar 15, 2024
2 checks passed
@luizakp luizakp deleted the input-disabled branch March 15, 2024 16:31
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