-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
dcc.Input value on page load vs. after deleting contents #162
Comments
I think I've run into this gotcha before. While this seems to contradict Dash's stateless nature, I actually don't think it does. Dash is intended to be stateless on the server-side however it should very much be stateful on the client-side, as we expect the results of callbacks to change depending on the current contents of the user's DOM. In this example, the Dash Inputs only are assigned
So when a user modifies the contents of an input element with no I think this means that either you want to provide an initial |
I can roll with that explanation of the behavior. Thanks @ned2 ! For others, the key takeaway for me was this:
That's what I will consider best practice now. |
Don't display "PreventUpdate" errors in the dev tools UI
Hey, what would be the best way to go about from implementing a |
I just stumbled on unexpected behavior and I'm not sure if it should be considered a bug, or if this is desired. In my code, I let the user fill in some text boxes, then click a button which triggers the callback. I was forming a list of the non-blank
dcc.Input
contents using a check fornot None
. Here's an example:In real life, I'm doing an API call; during some debugging I noticed that the call was failing. It turned out that after deleting a box and re-running, my
not None
check didn't work since the box now contained''
.I've been converting my mind to this sentiment from @chriddyp :
In a sense, the input boxes have been "tampered with", so I get why it's happening, but visually, the "state" would seem to be the same as at page load. How would one differentiate a "truly empty" box vs. one that's been erased?
Now that I've caught the "gotcha," I could change my check to look for
None
or''
. Is that best practice? Or perhaps I should have been initializing to''
all along vs. relying onNone
? Otherwise, it seemsdash
will, by default, differentiate between "original state" and "returned to original state"?Thanks for any suggestions!
The text was updated successfully, but these errors were encountered: