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

[useInput] Add return value interface #36036

Merged
merged 6 commits into from
Feb 8, 2023

Conversation

Shorifpatwary
Copy link
Contributor

@Shorifpatwary Shorifpatwary commented Feb 3, 2023

UseInput return value interface

I tried to add a return interface to UseInput MUI Base Hooks (Those hooks are defined in this issue #35933).

Sorry, something went wrong.

@mui-bot
Copy link

mui-bot commented Feb 3, 2023

Messages
📖 Netlify deploy preview: https://deploy-preview-36036--material-ui.netlify.app/

No bundle size changes

Generated by 🚫 dangerJS against 62ddbc9

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

The types look correct 👍 Let's wait on Sam's response for the description of the props.


export interface UseInputReturnValue {
/**
* If `true`, the component is disabled.
Copy link
Member

Choose a reason for hiding this comment

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

We use present here, but future int he error prop description. Also, I wonder if for the hooks we shouldn't use a phrase like:

"If true it indicates that the component it ...."

@samuelsycamore for thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I think in a situation like this, the future tense is preferable. "If X, then Y will be Z." It helps clarify cause and effect this way—Y becomes Z because of X. In the current version, the cause and effect are not as clear.

*/
required: boolean;
/**
* `value` of input element.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* `value` of input element.
* The `value` of input element.

@mnajdova mnajdova changed the title add useInput return value interface [useInput] Add return value interface Feb 3, 2023
@mapache-salvaje
Copy link
Contributor

@mnajdova this is somewhat tangential, but as I'm reviewing these descriptions, I'm realizing that we don't have clear guidelines for styling and formatting these. In the Component docs we try to be precise about the Material UI Input component vs. the concept of an input vs. the <input> HTML tag vs. the <Input /> React component, but I don't see that here and it could potentially cause confusion. Not a blocker here, but it's something we should zoom out on and consider.

Copy link
Contributor

@mapache-salvaje mapache-salvaje left a comment

Choose a reason for hiding this comment

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

Thanks @Shorifpatwary !

@Shorifpatwary
Copy link
Contributor Author

Thanks, @mnajdova and @samuelsycamore.

Comment on lines +65 to +72
"description": "Resolver for the input slot's props."
},
"required": true
},
"getRootProps": {
"type": {
"name": "<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseInputRootSlotProps<TOther>",
"description": "Resolver for the root slot's props."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Resolver for the input slot's props."
},
"required": true
},
"getRootProps": {
"type": {
"name": "<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseInputRootSlotProps<TOther>",
"description": "Resolver for the root slot's props."
"description": "Resolver for the `input` slot's props."
},
"required": true
},
"getRootProps": {
"type": {
"name": "<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseInputRootSlotProps<TOther>",
"description": "Resolver for the `root` slot's props."

@samuelsycamore one last question :) Should we consider the slots' names as code elements too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question! I have not been styling slot names in any special way—here's an example from the Base docs:

Screenshot 2023-02-06 at 10 01 12 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say it makes sense to use back ticks when referring specifically to the class name: so either "the root slot" or MuiSwitch-root.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, in this case I am merging the PR, no need for additional changes.

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

@Shorifpatwary please revert the last commit, as we decided not to go with #36036 (comment) Next time, I would recommend waiting for a resolution before committing :)

@mnajdova mnajdova merged commit f16642b into mui:master Feb 8, 2023
@mnajdova
Copy link
Member

mnajdova commented Feb 8, 2023

Thanks for the work @Shorifpatwary! It's a great first pull request on MUI 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: base-ui Specific to @mui/base typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants