-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
InputControl: Improve type annotations and stories #40119
Conversation
`InputControl` itself does not accept `Flex` props. Only `InputBase` does.
@@ -65,7 +66,7 @@ export function InputBase( | |||
size = 'default', | |||
suffix, | |||
...props | |||
}: InputBaseProps, | |||
}: InputBaseProps & FlexProps, |
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 believe this is the correct placement of FlexProps
. See a682653
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 think that normally we have "merged" prop types in the types.ts
file (similarly to how the code was before the changes in this PR).
Is the reason for this to avoid that InputControlProps
inherits FlexProps
from InputBaseProps
? I wonder if those FlexProps
were ever passed to InputControl
(in that case, removing them could be seen as a breaking change?)
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 think that normally we have "merged" prop types in the types.ts file (similarly to how the code was before the changes in this PR).
Ah ok, I'll keep the logic in the types.ts file. 53b7e08
Is the reason for this to avoid that
InputControlProps
inheritsFlexProps
fromInputBaseProps
?
Correct 👍
I verified that any FlexProps
passed to InputControl
would have been passed through (via ...props
) to an <input>
, where they would have no effect. So I think we're ok.
onDragEnd?: ( dragProps: DragProps ) => void; | ||
onDragStart?: ( dragProps: DragProps ) => void; | ||
onDrag?: ( dragProps: DragProps ) => void; |
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.
We're lacking in documentation for the drag stuff overall 😓 I'd say it's low priority though.
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.
Yeah, that's not an easy one because we want to be careful to document it in a way that doesn't necessarily expose the @use-gesture/react
library as a dependency, in case we want to swap it in the future.
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.
Currently the generated type for these props is a bit convoluted ((dragProps: Omit<FullGestureState<"drag">, "event"> & { event: unknown; }) => void
), do you think it's ok to keep it as-is, or should we try to simplify it at least for the docs description?
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.
Honestly I don't know what that "simplified" version would be 😅 I'm fine with keeping it as is for now, because it's probably irrelevant for 99% of consumers, at least without proper documentation.
Also TIL you can override type info in the args table. Nice option to have (when it's worth the maintenance cost)!
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.
Agreed, let's keep it as-is and improve it later if/when necessary
Also TIL you can override type info in the args table. Nice option to have (when it's worth the maintenance cost)!
That's very useful, definitely good to know!
Size Change: -202 B (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
* If true, the label will only be visible to screen readers. | ||
* | ||
* @default false | ||
*/ | ||
hideLabelFromVision?: boolean; | ||
isFocused: boolean; |
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.
Should we also add docs for isFocused
(including the false
default 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.
Sure thing. Does this description look correct? 128618a
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.
Yep, looks good!
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.
Thank you for working on this — some of the types needed a polish, and the Storybook examples are much better!
I left a few inline comments, but overall the changes are looking good!
Thanks for the review @ciampo, feedback has been addressed ✅ |
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.
LGTM 🚀
onDragEnd?: ( dragProps: DragProps ) => void; | ||
onDragStart?: ( dragProps: DragProps ) => void; | ||
onDrag?: ( dragProps: DragProps ) => void; |
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.
Agreed, let's keep it as-is and improve it later if/when necessary
Also TIL you can override type info in the args table. Nice option to have (when it's worth the maintenance cost)!
That's very useful, definitely good to know!
* If true, the label will only be visible to screen readers. | ||
* | ||
* @default false | ||
*/ | ||
hideLabelFromVision?: boolean; | ||
isFocused: boolean; |
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.
Yep, looks good!
Part of #35665
In preparation for #39397
What?
InputControl
to be auto-generated.Why?
To improve the quality and accuracy of our documentation.
How?
Testing Instructions
npm run storybook:dev
InputControl
and compare with https://wordpress.github.io/gutenberg/?path=/docs/components-experimental-inputcontrol--default