dcc redesign: refactor TextArea and Tooltip#3468
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.
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.
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.
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.
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
This PR is a small refactor of
TextareaandTooltipcomponents to match the current designs and be Typescript components.