Add a checkbox which is checked by default. Clicking on it should uncheck the box.
Clicking on the checked by default box does not uncheck it.
Add a model with a Boolean field with default value set to true:
import keystone from 'keystone';
const Types = keystone.Field.Types;
const Page = new keystone.List('Page');
Page.add({
show : { type: Types.Boolean, label: 'Show this page?', default: true, initial: true }
});
Page.register();
Try and uncheck the checkbox.
| Software | Version
| ---------------- | -------
| Keystone | 4.0.0
| Node.js | 9.3.0
| Browser | Chrome 67
Seeing same issue. Works fine on RC1
I can repro the bug for a Boolean field with default:true. Note: this doesn't happen for a Boolean field with default: false.
@chrisschaub Thanks for confirming that this behaviour changed between 4.0.0 RC1 and GA (default works as expected for me in RC1).
I don't see any direct changes for Boolean fields, so this may be an unexpected consequence of adding semver to dependencies.
Regards,
Stennie
I'm experiencing the same issue on Keystone 4.0.0.
Any news? I can't uncheck checkboxes.
I have noticed a similar issue with Type Integer with default set to 1 -- Keystone refuses to let me set it to zero.
copying comments from @MadMadlan's duplicate issue #4877:
We have a field that type is boolean and its default value is true.
On admin panel (list view) everything is ok, problem is with item view.
On item view field even when its value is false (unchecked) seems to be marked as true. It is also impossible to uncheck this field.
I tested this on keystone 4.0.0 and keystone 4.0.0-beta.4. On 4.0.0-beta4 it is ok problem is with version 4.0.0
Hmm. Just wondering if the cause could be here: https://github.com/ttsirkia/keystone/blob/master/admin/client/App/screens/Item/components/EditForm.js#L87 That was added in #4698 as explained in the description.
This
props.value = this.state.values[field.path] === undefined ? field.defaultValue : this.state.values[field.path];
may resolve the problem but I can't test it now.
I confirm that that the code suggestion above for EditForm will fix the issue.
Guys, this issue was submitted on July 26. It's still reproduced and that's a problem for some releases.
Will it be fixed in nearest future?
I haven't made PR because haven't had time to see how to make proper unit tests. If a PR is accepted without them, I'm happy to submit it.
Issue happens for me too.
Kinda disappointed that this didn't make the cut for 4.1.0. In the meantime, turning off "default: true"
@jbfolkerts, 4.1.0 was about bringing Keystone dependencies up to date, which was an unfortunately difficult process. A group of us who have recently started to actively maintain the repo are aware of the issue and will be working to fix it in one of the upcoming releases. Issues with field types not working correctly are high on the list. If you're interested in being a part of the discussion, feel free to join the Keystone Slack, specifically the v4-maintenance channel.
In addition to what @autoboxer said, for 4.1.0 we were mostly focused on landing PRs that had come in (or been merged) and making sure we got them released. We'll start looking at important issues next.
If you're not sure how to add tests but want to open a PR for this anyway, that would help move this along and we can work out what to do from a testing standpoint when it's being reviewed 👍
Made a PR that will fix the issue.
Most helpful comment
Seeing same issue. Works fine on RC1