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

Support scala-js-snabbdom-0.2.0-M3 and lazy property setting #284

Closed
wants to merge 5 commits into from

Conversation

sloshy
Copy link
Contributor

@sloshy sloshy commented Aug 26, 2024

EDIT: PR is unnecessary and came from my lack of understanding how snabbdom keys are meant to be used. See comment below.


This PR comes from troubleshooting strange behavior in a webapp I'm making where the value property on some elements could sometimes not appear to update as I'd expect. In trying multiple solutions such as setting keys on the elements I'm updating, the only solution I've found that works is a combination of the following:

  • updating scala-js-snabbdom to 0.2.0-M3
  • Adding a way to hint to tyrian that you want properties applied later in the rendering process (Html#setLazy)

Part of the reason why this works is that the behavior of the Props module in scala-js-snabbdom has changed between versions. In particular it no longer filters out the value property on updates. Trying to add setLazy to the branch supporting v0.1.0 does not fix the issue.

The way this is meant to work is, you will add .setLazy onto any elements that are exhibiting strange property-setting behavior, to delay setting those properties until after every other element is updated. If it's added to a normal element, it may change behavior, so it's only meant to be used in strange edge-cases where values or other properties appear as if they are not correctly being set.

Alternatively -- if you can think of a more elegant way to solve the issues I've been experiencing without this kind of hack-ish solution, or without supporting a milestone-version of this library, I would love to hear it. I'm personally a bit nervous about this requiring a milestone version of scala-js-snabbdom and it has not been updated in quite some time. That being said, the behavior has not actually changed all that much from v0.1.0 from the looks of things and everything else appears to work as I'd expect so far, so YMMV.

@sloshy
Copy link
Contributor Author

sloshy commented Aug 26, 2024

After digging a bit more into how I'm supposed to use keys, it appears this is entirely unnecessary. The issue I was experiencing was solved by making sure that all of the children of the select element also had keys.

In my defense I've been a bit sick recently so maybe my head's messed up. No worries and thanks again for the great project!

@sloshy sloshy closed this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant