-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
No select example? #711
Comments
Yeah, you're right — no example in the REPL, which is ironic since you select examples with a two-way bound select element! Sounds like you've found a bug — are you able to reproduce it in the REPL? Thanks |
Managed to reproduce the issue: https://svelte.technology/repl?version=1.25.0&gist=d67ed619d2c308b9a20518fa694d64ac note that after toggling, the duration is still correctly rendered, but the select is defaulted. |
I have the same code in my project but without IF statement in the nested component and all work fine. I think IF break all again. |
Yeah, the The dropdown defaults to its original settings because the |
If anybody else runs into this, I've managed a pretty ugly workaround using event firing. I struggled for a while as it's a dealbreaker for our use case (I'm dealing with loan calculations, so I definitely can't have incorrect calculations showing.), but I eventually resorted to this, which does work until this issue is resolved: This resets my value to its original state, which in turn updates the calculated data to the correct values. oncreate () {
this.refs.modal.on('show', e => {
// https://github.com/sveltejs/svelte/issues/711
this.refs.otherComponent.set({ myValue: 12 })
})
} in my modal component, the show method now looks like this, so that an event is fired before the user sees the calculation: methods: {
show: function () {
this.fire('show')
this.set({ shown: true })
}
} |
ensure data is up to date when re-rendering yield blocks
Thanks! This is fixed in 1.26 |
Aweeeesome! Now I can strip out all the ugly code from my widget :D |
Your fix broken binding in a cycle. I think you should reopen this bug. |
Fast fix: diff --git a/src/generators/dom/visitors/Element/Binding.ts b/src/generators/dom/visitors/Element/Binding.ts
index b3c72fd..945145c 100644
--- a/src/generators/dom/visitors/Element/Binding.ts
+++ b/src/generators/dom/visitors/Element/Binding.ts
@@ -87,8 +87,16 @@ export default function visitBinding(
const { name } = getObject(attribute.value);
const tailSnippet = getTailSnippet(attribute.value);
- updateElement = deindent`
- var ${value} = #component.get( '${name}' )${tailSnippet};
+ if (state.inEachBlock === true) {
+ updateElement = deindent`
+ var ${value} = ${snippet};
+ `;
+ } else {
+ updateElement = deindent`
+ var ${value} = #component.get( '${name}' )${tailSnippet};
+ `;
+ }
+ updateElement += `
for ( var #i = 0; #i < ${state.parentNode}.options.length; #i += 1 ) {
var ${option} = ${state.parentNode}.options[#i]; |
I have a select box in my component which binds a value using two-way bindings.
The component is nested inside a modal component which can show and hide.
It seems that when I hide and re-show the modal, whilst the 'duration' value has been persisted, the select has reset to the initial list item.
It seems like the two-way binding doesn't bind the selected value correctly.
It also appears that there is no
<select>
example available in the REPL.Is there another binding I require, or is this an issue?
The text was updated successfully, but these errors were encountered: