-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
'enabled' property on 'choice' object does not enable choice by default #270
Comments
This is a bug. Thanks for reporting. |
Hey @doowb, Is this still open? If yes, I would like to try and fix it. |
Just had this issue as well |
Any traction on this? Spent some time trying to figure out what I was doing wrong while following the docs, and had to come here to find out that it's been broken for over a year. I'm using |
Any luck for the basic functionality to be fixed? This is still a thing |
The issue appears to be in the this.choices.forEach(ch => (ch.enabled = false)); If I comment out the line above then my default values are properly shown as already selected when my The async initialize() {
if (typeof this.options.initial === 'function') {
this.initial = await this.options.initial.call(this);
}
await this.reset(true);
await super.initialize();
}
async reset() {
let { choices, initial, autofocus, suggest } = this.options; I wonder if that parameter was originally supposed to tell the Maybe something like this to fix the issue?: async initialize() {
if (typeof this.options.initial === "function") {
this.initial = await this.options.initial.call(this);
}
await this.reset({ doNotResetEnabled: true });
await super.initialize();
}
async reset({ doNotResetEnabled = false }) {
let { choices, initial, autofocus, suggest } = this.options;
this.state._choices = [];
this.state.choices = [];
this.choices = await Promise.all(await this.toChoices(choices));
if (!doNotResetEnabled) {
this.choices.forEach((ch) => (ch.enabled = false));
} So now a new |
Actually, my change above broke a load of tests. It seems that the first item list was always being enabled by default, and that threw the test counts out. This is the code that was causing that. It's in the ele.path = parent ? parent.path + "." + ele.name : ele.name;
ele.enabled = !!(
this.multiple &&
!this.isDisabled(ele) &&
(ele.enabled || this.isSelected(ele))
); The first line is always selected by default. The line I changed it to remove the ele.path = parent ? parent.path + "." + ele.name : ele.name;
ele.enabled = !!(
this.multiple &&
!this.isDisabled(ele) &&
ele.enabled
); Now tests are passing. |
Can I get a review on my PR for this one, please, @jonschlinkert ? It's #447 . |
I apologize if I am doing something incorrectly, but when I run the code below, the 'hello' choice is not enabled by default.
The 'hello' choice appears as normal, but the checkmark next to it is grey, not green as expected. Am I doing something wrong, or is there a bug here? Thank you for any help you can give me! (BTW, awesome package!)
The text was updated successfully, but these errors were encountered: