Closed steph643 closed 7 years ago
Please make a minimum repro (without the bootstrap stuff). The following works as expected:
ViewModel.share({
alertBucket: {
alert: undefined
}
})
Template.body.viewmodel({
share: 'alertBucket',
show(){
this.alert({ text: "AAAA"})
}
});
<body>
<button {{b "click: show"}}>Alert</button>
{{#if alert}}
<h1 {{b "text: alert.text"}}></h1>
{{/if}}
</body>
Here is the minimal code to reproduce the issue:
main.html
<body>
{{> header}}
{{> form}}
</body>
<template name="header">
<h1>Bug ViewModel</h1>
{{#if unusedFlag}}{{/if}}
</template>
<template name="form">
<p>Please enter your name below:</p>
<input type="text" {{b "value: name"}}>
<button type="button" {{ b "enable: valid"}}>Ok</button>
<p>The Ok button should activate when you input a non-blank name. But it doesn't...</p>
</template>
main.js
ViewModel.share({
sharedProps: {
unusedFlag : undefined // Set it to null to fix the bug
}
});
Template.header.viewmodel({
share: 'sharedProps'
});
Template.form.viewmodel({
share: 'sharedProps',
name: ViewModel.property.string.notBlank
});
Please let me know if you still need a repo.
Thanks, I'll fix it.
btw, it's not exclusive to shared properties. You get the same behavior with regular properties initialized to undefined (the VM will stay invalid).
Pick up v6.2.1 Thanks!
Here is my code:
With this code, the button is never enabled, even when all fields are valid. If I replace
alert : undefined
byalert : null
, the code works as expected.