-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add FeedbackButton to DeleteDialog of CrudContextMenu #2237
Conversation
…bars on success and error
… for state updates
loading?: boolean; | ||
hasErrors?: boolean; | ||
Omit<LoadingButtonProps, "loading"> { | ||
onClick: () => Promise<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.
@nsams @thomasdax98 what do you think about using the promise states (pending, resolved, rejected) to handle the display states of the button instead of loading
, hasErrors
etc. props? I think this is easier to understand and less error-prone as the state transitions are pretty clear. Could there be use cases where I wouldn't want to have this?
…create a non-breaking change
I added a flag called |
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.
It should be possible to make this a non-breaking change targeting main. Also, should we move the Promise detection into a separate PR and discussion?
} | ||
|
||
export interface FeedbackButtonPropsPromise extends FeedbackButtonPropsBase { | ||
feedbackStateControl: "onClickPromise"; |
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.
Couldn't this be inferred based on the passed onClick handler? Is it possible to detect if a function is async or not?
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.
There are ways but it's not straightforward and probably also not reliable. Additionally, it is way more descriptive with the flag. So users will actually understand whats going on.
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.
@nsams @thomasdax98 what do you think?
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 would prefer a solution that doesn't need this feedbackStateControl
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.
Okay. The other two options I can think of are:
- Somehow infer from function if it is async or not
- Add a second
onClickAsync
prop for the promise-based usage
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.
That's too late unfortunately. I could infer that a user wants to rely on outside state if loading and/or hasError is not 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.
That's too late unfortunately. I could infer that a user wants to rely on outside state if loading and/or hasError is not undefined 🤷🏻♂️
I like this idea! Could you please try this? Also, I'd still recommend adding the promise detection in a separate PR: #2237 (review)
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.
Added a new PR for the changes to CrudContextMenu: #2423
Was easier to do it like this since the current PR targets next. I'll add another one for the addition of the promise feature.
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.
Here to following PR: #2425
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 will close this one
hasErrors?: undefined; | ||
loading?: 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.
hasErrors?: undefined; | |
loading?: undefined; | |
hasErrors?: never; | |
loading?: never; |
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.
loading?: boolean; | ||
hasErrors?: boolean; | ||
Omit<LoadingButtonProps, "loading"> { | ||
feedbackStateControl: FeedbackStateControl; |
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 would need to be optional to not be 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.
…non-breaking change
…ors and loading in FeedbackButtonPropsPromise
This was done to give the user feedback if something is loading and/ or goes wrong. Additionally, the
FeedbackButton
was reworked to use Promises for state updates, which simplifies the usage. This was done after a discussion with @johnnyomair.PR Checklist
Screenshots/screencasts
Screen.Recording.2024-07-01.at.17.03.09.mov