Skip to content
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

Resolve issue with selection mismatch between autocomplete and checkbox #3674

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@
</template>

<template #item="{ item }">
<div style="width: 100%; height: 100%">
<VDivider v-if="!item.value.includes('.')" />
<VListTile
:value="isSelected(item.value)"
:class="{ parentOption: !item.value.includes('.') }"
@mousedown.prevent
@click="() => !isSelected(item.value) ? add(item.value) : remove(item.value)"
>
<KCheckbox
:checked="dropdownSelected[item.value]"
:checked="isSelected(item.value)"
:label="item.text"
:value="item.value"
style="margin-top: 10px"
:style="treeItemStyle(item)"
:ripple="false"
@change="checked => checked ? add(item.value) : remove(item.value)"
/>
</div>
</VListTile>
</template>
</VAutocomplete>
</div>
Expand Down Expand Up @@ -143,19 +146,6 @@
};
});
},
dropdownSelected() {
const obj = {};
for (let category of this.selected) {
const paths = category.split('.');
let cat = '';
for (let path of paths) {
cat += path;
obj[cat] = true;
cat += '.';
}
}
return obj;
},
selected: {
get() {
return this.value;
Expand All @@ -167,16 +157,19 @@
nested() {
return !this.categoryText;
},
isSelected() {
return value => this.selected.some(v => v.startsWith(value));
},
},
methods: {
treeItemStyle(item) {
return this.nested ? { paddingLeft: `${item.level * 24}px` } : {};
},
add(item) {
this.selected = [...this.selected, item];
add(value) {
this.selected = [...this.selected, value];
},
remove(item) {
this.selected = this.selected.filter(i => !i.startsWith(item));
remove(value) {
this.selected = this.selected.filter(i => !i.startsWith(value));
},
removeAll() {
this.selected = [];
Expand Down Expand Up @@ -220,12 +213,8 @@
position: relative;
}

/deep/ .v-list__tile {
flex-wrap: wrap;
}

/deep/ div[role='listitem']:first-child hr {
display: none;
.parentOption:not(:first-child) {
border-top: 1px solid rgba(0, 0, 0, 0.12);
}

</style>