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

[BUG] FtResponse breaks toasts #486

Open
jsandeo opened this issue Oct 1, 2024 · 0 comments
Open

[BUG] FtResponse breaks toasts #486

jsandeo opened this issue Oct 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jsandeo
Copy link

jsandeo commented Oct 1, 2024

Describe the bug
Wrapping the response with FtResponse() apparently breaks toasts, meaning the toast won't show in the browser.

Minimal Reproducible Example

from fasthtml.common import *

app, rt = fast_app(hdrs=(picolink,))
setup_toasts(app)

@rt("/")
def get(sess):
  add_toast(sess, 'This toast will show!', 'success')
  return Div('Aloha!')

@rt("/notoast")
def get(sess):
  add_toast(sess, 'This toast won\'t show!', 'success')
  return FtResponse(Div('Aloha!'))

serve()

Expected behavior
Toasts should show in the browser.

Environment Information
Please provide the following version information:

  • fastlite version: 0.0.10
  • fastcore version: 1.7.9
  • fasthtml version: 0.6.9

Confirmation
Please confirm the following:

  • [✓] I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • [✓] I have provided a minimal reproducible example
  • [✓] I have included the versions of fastlite, fastcore, and fasthtml
  • [✓] I understand that this is a volunteer open source project with no commercial support.

Additional context
I used FtResponse() so I could set a non-200 status_code for the response (such as 422 for a form POST having validation errors), maybe there is a simpler way to do just that... but I guess toasts should work anyway when using FtResponse().

Screenshots
toast
notoast

@jsandeo jsandeo added the bug Something isn't working label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant