ui icon indicating copy to clipboard operation
ui copied to clipboard

toast action with button issue in its isLoading prop

Open RenzoBA opened this issue 1 year ago • 2 comments

I've created a toast with 2 buttons (delete and cancel) like this: image

with this source code: image

The issue is that when I click on the Delete button, the button does not change its "isLoading" property to true, and it appears as if nothing is loading. In other words, I would like to see the spinner on the left side of the word "Delete" when I click on it. Like this: image

Note: I have confirmed that the value of "isDelLoading" is working correctly (it changes to true when I click the delete button).

RenzoBA avatar Oct 04 '23 16:10 RenzoBA

I have a similar problem that is only happening on mobile. I display the toast like this:

      toast({
        title: "Are you sure?",
        description: "The more questions you answer, the more accurate your recommendations will be.",
        action: <ToastAction altText="generate" onClick={getRecommendations}>Generate</ToastAction>,
        duration: 5000,
      }); 

But, clicking "generate" on mobile, does not seem to register. Any update on this?

smaldd14 avatar Dec 02 '23 02:12 smaldd14

@smaldd14 I'm running into the same issue on mobile. I believe it has to do with the first tap on the ToastAction being used to focus the toast element, and the 2nd tap on the button actually fires the onClick of the provided ToastAction.

I think this doesn't occur on desktop because the users mouse hover before clicking the ToastAction focuses the Toast (unlike on mobile). One can test this by interacting with the docs' Toast with action example on mobile: https://ui.shadcn.com/docs/components/toast#with-action (it takes two taps of "Try Again" to dismiss the toast)

Not sure if there are any solutions at this time - I'm trying to see if I can add an onClick handler to the entire Toast element rather than just the ToastAction.

jdamon96 avatar Feb 08 '24 15:02 jdamon96

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Mar 04 '24 23:03 shadcn