Skip to content

Commit

Permalink
fix(default-theme): sync up data in some filter component (#2009)
Browse files Browse the repository at this point in the history
  • Loading branch information
quando1910 committed Oct 11, 2023
1 parent bf0eca9 commit 7b9685d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
17 changes: 14 additions & 3 deletions packages/default-theme/src/components/listing/types/range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
</div>
</template>
<script>
import { computed, ref } from "@vue/composition-api"
import { watch, ref } from "@vue/composition-api"
import { SfFilter, SfHeading } from "@storefront-ui/vue"
import SwInput from "@/components/atoms/SwInput.vue"
import useVuelidate from "@vuelidate/core"
import { required, email } from "@vuelidate/validators"
export default {
components: {
Expand Down Expand Up @@ -72,6 +70,19 @@ export default {
value: max.value,
})
}
watch(() => props.currentFilters[minFilterCode], (v) => {
if (min.value !== v) {
min.value = v;
}
});
watch(() => props.currentFilters[maxFilterCode], (v) => {
if (max.value !== v) {
max.value = v;
}
});
return {
min,
max,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
</div>
</template>
<script>
import { computed, ref } from "@vue/composition-api"
import { SfFilter, SfHeading } from "@storefront-ui/vue"
import SwInput from "@/components/atoms/SwInput.vue"
import SwCheckbox from "@/components/atoms/SwCheckbox.vue"
Expand All @@ -30,7 +28,7 @@ export default {
},
data() {
return {
selected: this.currentFilters[this.filter.code] === "true",
selected: this.currentFilters[this.filter.code] === true,
}
},
props: {
Expand All @@ -43,6 +41,11 @@ export default {
default: () => ({}),
},
},
watch: {
currentFilters(val) {
this.selected = val[this.filter.code] === true;
},
},
}
</script>
<style lang="scss" scoped>
Expand Down

0 comments on commit 7b9685d

Please sign in to comment.