FIX: select-kit perf and positioning improvements (#7093)

This commit is contained in:
Joffrey JAFFEUX 2019-03-04 10:30:22 +01:00 committed by GitHub
parent dc4001370c
commit 2e881adb6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -331,20 +331,31 @@ export default SelectKitComponent.extend({
deselect(rowComputedContentItems) {
this.willDeselect(rowComputedContentItems);
rowComputedContentItems = makeArray(rowComputedContentItems);
const generatedComputedContents = this._filterRemovableComputedContents(
makeArray(rowComputedContentItems)
);
this.set("highlighted", null);
this.set("highlightedSelection", []);
this.setProperties({ highlighted: null, highlightedSelection: [] });
this.get("computedValues").removeObjects(
rowComputedContentItems.map(r => r.value)
);
this.get("computedContent").removeObjects(generatedComputedContents);
run.next(() => this.mutateAttributes());
run.schedule("afterRender", () => {
this.didDeselect(rowComputedContentItems);
this.autoHighlight();
this.get("computedContent").removeObjects([
...rowComputedContentItems,
...generatedComputedContents
]);
run.next(() => {
this.mutateAttributes();
run.schedule("afterRender", () => {
this.didDeselect(rowComputedContentItems);
this.autoHighlight();
if (!this.isDestroying && !this.isDestroyed) {
this._positionWrapper();
}
});
});
},

View File

@ -116,6 +116,7 @@ export default Ember.Mixin.create({
expand() {
if (this.get("isExpanded")) return;
this.setProperties({
isExpanded: true,
renderedBodyOnce: true,
@ -135,6 +136,8 @@ export default Ember.Mixin.create({
},
collapse() {
if (!this.get("isExpanded")) return;
this.set("isExpanded", false);
Ember.run.next(() => {