Clicking on a sortable table column header not working (not sort) when 'sortable' value is dynamic.
Like example below when default fields no sortable or sortable is false, then switch enableSortAble to true, column header is changed (there are arrow sort icon) but clicking the header column is not sorting the column.
<template>
<div>
<b-form-checkbox switch v-model="enableSortAble">
<span :class="enableSortAble ? 'font-weight-bold text-primary' : 'text-secondary'">Sortable</span>
</b-form-checkbox>
<b-table :items="items" :fields="fields" responsive="sm"></b-table>
</div>
</template>
<script>
export default {
data() {
return {
enableSortAble: false,
fields: [
{ key: "last_name" },
{ key: "first_name" },
{ key: "age" },
{ key: "isActive" }
],
items: [
{
isActive: true,
age: 40,
first_name: "Dickerson",
last_name: "Macdonald"
},
{ isActive: false, age: 21, first_name: "Larsen", last_name: "Shaw" },
{ isActive: false, age: 89, first_name: "Geneva", last_name: "Wilson" },
{ isActive: true, age: 38, first_name: "Jami", last_name: "Carney" }
]
};
},
watch: {
enableSortAble(newVal) {
this.fields = this.fields.map(el => {
return { ...el, sortable: newVal };
});
}
}
};
</script>
When click switch button to enable sortable, then clicking on a sortable column header will sort the column.
Describe the bug
Clicking on a sortable table column header not working (not sort) when 'sortable' value is dynamic.
Like example below when default fields no sortable or sortable is false, then switch
enableSortAbleto true, column header is changed (there are arrow sort icon) but clicking the header column is not sorting the column.Steps to reproduce the bug
Expected behavior
When click switch button to enable sortable, then clicking on a sortable column header will sort the column.
Versions
Libraries:
Environment:
Demo link
https://codesandbox.io/s/bvtable-sortable-g6lyz-g6lyz?file=/App.vue