I am trying to implement a feature where clicking on the TableHead should toggle between sorting by most stock on top and least stock on top. Currently, I have two buttons for this functionality, but it's not very user-friendly.
My approach involves using both single click and double click events, which work, but are not optimal for ease of use.
TableHead
<th scope="col" class="px-3 py-3.5 text-left text-sm font-medium text-gray-900 cursor-pointer" @click="sortBy='stockUp'" @dblclick="sortBy='stockDown'">
Stock
</th>
Variable Used for Sorting Preference:
const sortBy = ref('priceDown')
Sorting Function Logic:
watchEffect(() => {
// Sorting logic based on the chosen preference (eta, stock, or price)
})
Is there a more user-friendly way to achieve this functionality?