mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 02:49:29 +08:00
FIX: makes allowInitialValueMutation more restrictive
This commit is contained in:
parent
b3094e9954
commit
96cdc4e66e
|
@ -15,7 +15,7 @@
|
|||
{{/each}}
|
||||
</ul>
|
||||
{{#if editingPermissions}}
|
||||
{{combo-box content=category.availableGroups value=selectedGroup}}
|
||||
{{combo-box allowInitialValueMutation=true content=category.availableGroups value=selectedGroup}}
|
||||
{{combo-box class="permission-selector"
|
||||
nameProperty="description"
|
||||
content=category.availablePermissions
|
||||
|
|
|
@ -11,7 +11,7 @@ export default SelectKitComponent.extend({
|
|||
classNames: "single-select",
|
||||
computedValue: null,
|
||||
value: null,
|
||||
allowInitialValueMutation: true,
|
||||
allowInitialValueMutation: false,
|
||||
|
||||
@on("didReceiveAttrs")
|
||||
_compute() {
|
||||
|
@ -47,6 +47,10 @@ export default SelectKitComponent.extend({
|
|||
},
|
||||
|
||||
_beforeWillComputeValue(value) {
|
||||
if (!isEmpty(this.get("content")) && isEmpty(value) && isNone(this.get("none"))) {
|
||||
value = this.valueForContentItem(get(this.get("content"), "firstObject"));
|
||||
}
|
||||
|
||||
switch (typeof value) {
|
||||
case "string":
|
||||
case "number":
|
||||
|
@ -58,10 +62,6 @@ export default SelectKitComponent.extend({
|
|||
willComputeValue(value) { return value; },
|
||||
computeValue(value) { return value; },
|
||||
_beforeDidComputeValue(value) {
|
||||
if (!isEmpty(this.get("content")) && isEmpty(value) && isNone(this.get("none"))) {
|
||||
value = this.valueForContentItem(get(this.get("content"), "firstObject"));
|
||||
}
|
||||
|
||||
this.setProperties({ computedValue: value });
|
||||
return value;
|
||||
},
|
||||
|
|
|
@ -282,8 +282,8 @@ componentTest('supports keyboard events', {
|
|||
});
|
||||
|
||||
|
||||
componentTest('supports mutating value when no value given', {
|
||||
template: '{{single-select value=value content=content}}',
|
||||
componentTest('with allowInitialValueMutation', {
|
||||
template: '{{single-select value=value content=content allowInitialValueMutation=true}}',
|
||||
|
||||
beforeEach() {
|
||||
this.set("value", "");
|
||||
|
@ -292,7 +292,7 @@ componentTest('supports mutating value when no value given', {
|
|||
|
||||
test(assert) {
|
||||
andThen(() => {
|
||||
assert.equal(this.get("value"), "1");
|
||||
assert.equal(this.get("value"), "1", "it mutates the value on initial rendering");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user