-
Notifications
You must be signed in to change notification settings - Fork 10
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
Signal prematurely cycling #12
Comments
I just pushed another commit to the branch; this is interesting: refresh==true gets all the way into type RefreshString = {ref :: Boolean, str:: String}
textInputWidget :: RefreshString -> Widget HTML RefreshString
textInputWidget rs = do
log $ "textInputWidget: " <> (show rs.ref) <> " " <> rs.str
txtNew <- D.input [valProp rs.str, P.unsafeTargetValue <$> P.onChange]
pure {ref: rs.ref, str: txtNew}
where
valProp = if rs.ref then P.value else P.defaultValue
textInput' :: Boolean -> CtrlSignal HTML String
textInput' refresh initVal = do
refstrNew <- sigNow refstr
pure refstrNew.str
where
refstr = {ref: refresh, str: initVal}
sigNow rs = step rs $ do
pure $ unsafePerformEffect $ log $ "refstr in textInput sigNow': " <> (show rs)
rsNew <- textInputWidget rs
pure $ sigNow rsNew
sig rs = do
pure $ unsafePerformEffect $ log $ "refstr in textInput sig': " <> (show rs)
debounce 500.0 rs textInputWidget This happens regardless of whether or not So it seems somewhat likely there is a problem with |
Hi @bbarker I will look at this (and the other issue you reported) over this weekend. |
It also occurs to me that I probably don't need |
I added a hack to workaround the issue. This is not a solution as you will see, but it does seem to work, so that may provide another data point. I manually modify the DOM after doing a serach for input elements. In the signal that creates a txtMay :: Maybe NonEmptyString <- D.div_ [P._id mjUI_dateInput]
$ textInput refresh (fromString prevTxt) -- assumes this id is unique ... (hack) :
pure $ unsafePerformEffect $ setChildInputByTag mjUI_dateInput "INPUT" prevTxt The function is defined like: windowDoc :: Effect Document
windowDoc = do
win <- window
hDoc <- document win
pure $ HTML.toDocument hDoc
setChildInputByTag :: String -> String -> String -> Effect Unit
setChildInputByTag id tag value = do
doc <- windowDoc
let root = toNonElementParentNode doc
parEleMay <- getElementById id root
case parEleMay of
Just parEle -> do
let par = Ele.toParentNode parEle
childCollection <- children par
childArray <- HTML.toArray childCollection
let childMatches = filter (\c -> Ele.tagName c == tag) childArray
let childInputs = catMaybes $ HTML.fromElement <$> childMatches
-- log $ "Child array tags: " <> (show $ Ele.tagName <$> childArray) -- DEBUG
when (length childMatches == 0) $ log
$ "No children of " <> id <> " with tag == " <> tag
when (length childInputs == 0) $ log
$ "No input element children of " <> id <> " with tag == " <> tag
for_ childInputs (HTML.setValue value)
Nothing -> log $ "in setChildByTag, couldn't find element with id " <> id |
By prematurely, I at least mean before I expect it to. This may be working as intended, as I've not isolated exactly where the problem occurs. I have confirmed it is NOT an issue with debounce by disabling it. In the
dateInput
branch (commit = https://github.com/labordynamicsinstitute/metajelo-ui/tree/058ae0f942a0a5a43d164aebd75a108ff17664c2 ) I have a lot of log statements enabled.I confirmed that the value
refresh
is set totrue
correctly when an XML file is loaded in the app (example file at https://labordynamicsinstitute.github.io/metajelo-web/), however,true
never fully propagates down to thetextInput
signal and associated widget, as can be seen from this log output:The end result is that, in some cases (namely dateInput, for some reason) won't update the value. I went down this route of adding
refresh
because I noticed that fordateInput
, usingP.value
instead ofP.defaultValue
would allow it to be updated, but enabling that globally causes lag issues. Thus, I only want to do it whenrefresh == true
(that is, when a user uploads a file) -- otherwise, we stick todefaultValue
.The text was updated successfully, but these errors were encountered: