-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
dcc redesign: refactor TextArea
and Tooltip
#3468
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
Conversation
1f7f921
to
6bb0f4a
Compare
TextArea
and Tooltip
@T4rk1n please review |
const asNumber = (value?: string | number): number | undefined => { | ||
return typeof value === 'string' | ||
? isNaN(parseInt(value, 10)) | ||
? undefined | ||
: parseInt(value, 10) | ||
: value; | ||
}; | ||
const asBool = (value?: string | boolean): boolean | undefined => { | ||
if (typeof value === 'string') { | ||
if (['true', 'TRUE', 'True'].includes(value)) { | ||
return true; | ||
} | ||
if (['false', 'FALSE', 'False'].includes(value)) { | ||
return false; | ||
} | ||
return undefined; | ||
} | ||
return value; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think those conversion are necessary, the props are transfered in json and bool and number. The prop type should be bool or number but the string interpolation makes it harder on the python type check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your idea here, and pushed up a change that removes string
as an allowed type for these props.
However... these existed for API compatibility (the docs say string
is allowed) so just want you to be aware of the backwards incompatibility that this introduces (especially for numeric props like cols
and maxLength
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The html textarea cols/maxLength can accept string, but we didn't do the explicit conversion before. I think those props should follow what is in the react props for that html attributes.
interface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {
autoComplete?: string | undefined;
cols?: number | undefined;
dirName?: string | undefined;
disabled?: boolean | undefined;
form?: string | undefined;
maxLength?: number | undefined;
minLength?: number | undefined;
name?: string | undefined;
placeholder?: string | undefined;
readOnly?: boolean | undefined;
required?: boolean | undefined;
rows?: number | undefined;
value?: string | readonly string[] | number | undefined;
wrap?: string | undefined;
onChange?: ChangeEventHandler<T> | undefined;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we're agreeing here.. Numeric props no longer accept a string value. And that is the current state of this PR.
…r-textarea-tooltip' into feature/dcc-refactor-textarea-tooltip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃
This PR is a small refactor of
Textarea
andTooltip
components to match the current designs and be Typescript components.