Webiny-js: Cannot disable form inputs

Created on 17 Mar 2020  路  8Comments  路  Source: webiny/webiny-js

This is:

  • Bug

Detailed Description

Passing a disabled={true} prop on components like Input and Select does not have any effect. For example:

https://storybook.webiny.com/?path=/story/components-input--usage
https://storybook.webiny.com/?path=/story/components-select--usage

It works in the RMWC library - https://rmwc.io/text-fields.

Not sure where the bug is but if I hardcoded the disabled={true} in packages/ui/src/Input/Input.tsx:112, all inputs would become disabled as expected:

image

So, it seems that the flag is not correctly passed to the actual RMWC TextArea component.

bug good-first-issue

Most helpful comment

Actually that鈥檚 not correct, as you can see we compose types by importing the original Rmwc type and add our own props on top of that.

Also, TS doesn鈥檛 remove anything, no tools do. You can鈥檛 remove a prop from component; whatever is passed to component will be in the props object at runtime.

This is an interesting bug, I鈥檒l take a look at it as well.

All 8 comments

hey @doitadrian i've seen the Input component, is it possible for missing prop types cause this? i think the implementation is already good

@ahmad-reza619 what do you mean by missing prop types?

@Pavel910 the Input component has no disabled prop types, but it use disabled prop, so I think it automatically remove props that doesn't specified in prop type. It's just my guess actually, I never used typescript before

Actually that鈥檚 not correct, as you can see we compose types by importing the original Rmwc type and add our own props on top of that.

Also, TS doesn鈥檛 remove anything, no tools do. You can鈥檛 remove a prop from component; whatever is passed to component will be in the props object at runtime.

This is an interesting bug, I鈥檒l take a look at it as well.

I found the issue here. Actually, it's related to the Bind component and how it spreads props to the child component:

packages/form/src/Bind.ts:78:
image

Changing this to the following fixed the issue:

image

Is it already fixed?

@ahmad-reza619 nope, feel free to submit a PR if you'd like to take on this :)

Alright will do, but wow, i never thought another component is the cause of all this 馃 how is it even possible? is Bind forward it props to the children?

Was this page helpful?
0 / 5 - 0 ratings