FIX: prevents multi-select to use noneItem for its list (#17523)

This commit is contained in:
Joffrey JAFFEUX 2022-07-18 11:26:12 +02:00 committed by GitHub
parent fab1c00c8f
commit c94a011d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { render } from "@ember/test-helpers"; import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import { paste, query } from "discourse/tests/helpers/qunit-helpers"; import { exists, paste, query } from "discourse/tests/helpers/qunit-helpers";
const DEFAULT_CONTENT = [ const DEFAULT_CONTENT = [
{ id: 1, name: "foo" }, { id: 1, name: "foo" },
@ -118,4 +118,18 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
assert.equal(this.subject.header().value(), "1,2"); assert.equal(this.subject.header().value(), "1,2");
}); });
test("no value property with no content", async function (assert) {
setDefaultState(this);
await render(hbs`
<MultiSelect @valueProperty={{null}} />
`);
await this.subject.expand();
assert.notOk(
exists(".selected-content"),
"it doesnt render an empty content div"
);
});
}); });

View File

@ -156,7 +156,7 @@ export default SelectKitComponent.extend({
return this.selectKit.modifySelection(content); return this.selectKit.modifySelection(content);
} }
return this.selectKit.noneItem; return null;
} }
), ),

View File

@ -3,7 +3,7 @@
{{d-icon icon}} {{d-icon icon}}
{{/each}} {{/each}}
<MultiSelect::FormatSelectedContent @content={{this.selectedContent}} @selectKit={{this.selectKit}} /> <MultiSelect::FormatSelectedContent @content={{or this.selectedContent this.selectKit.noneItem}} @selectKit={{this.selectKit}} />
{{d-icon this.caretIcon class="caret-icon"}} {{d-icon this.caretIcon class="caret-icon"}}
</div> </div>