reflex-dom icon indicating copy to clipboard operation
reflex-dom copied to clipboard

inputElementConfig_initialValue doen't work after reload

Open pkaterski opened this issue 4 years ago • 4 comments

I think this is a bug. It is even present on https://reflex-frp.org/tutorial. If you open the page and look at tutorial4 and tutorial5 the first time it works as it should but after a reload the text inputs are empty (you can see that they load for a brief second and then they disappear). Basically this thing:

  x <- inputElement $ def & inputElementConfig_initialValue .~ "input"
  dynText $ _inputElement_value x

The issue is that after reloads the value loads just for a brief second and then it disappears. I've tried it on both Chrome and Firefox.

pkaterski avatar Nov 13 '20 20:11 pkaterski

Possibly related: https://github.com/reflex-frp/reflex-dom/pull/400

I can’t check that it’s fixed by that right now but this certainly rings a bell.

tomsmalley avatar Nov 13 '20 21:11 tomsmalley

Hi, I think the problem is still exist. any help?

and my code is the same as @pkaterski :

do
      el "h4" $ text "Initial Value"
      t2 <- inputElement $ def & inputElementConfig_initialValue .~ "input"
      dynText $ value t2

this is what i really want to do:

  do
      el "h4" $ text "Initial Value"
      t2 <- inputElement $ def & inputElementConfig_elementConfig . elementConfig_initialAttributes .~ ("value" =: "input") 
      -- t2 <- inputElement $ def & inputElementConfig_initialValue .~ "input"
      dynText $ value t2

I'm new here, so i may not understand the PR. Thanks!😭

MurakamiKennzo avatar Apr 17 '21 18:04 MurakamiKennzo

Just to confirm @tomsmalley - this issue is still present when using HEAD for reflex-dom. The logic is correct for loading the page for the first time, such as a direct url or link. However, when reloading the page, the issue remains the same as before - the placeholder text will flash for a second and then disappear.

The behaviour is also quite strange - I have another widget that depends on the Dynamic t Text produced by textAreaElement, and that Dynamic uses the correct initial value for a full second, but then after a good second at least, the Dynamic t Text is reset to "". Note that throughout this time, the value displayed in the textAreaElement is "". I wonder if the way text area elements work on refresh is subtly different?

santiweight avatar Oct 15 '21 21:10 santiweight

Apologies! This bug is actually fixed - I just made a mistake by only updating reflex-dom, but this fix is in fact spread across reflex-dom and reflex-dom-cre.

I recommend also closing https://github.com/reflex-frp/reflex-dom/issues/377

santiweight avatar Oct 15 '21 22:10 santiweight