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

Sorting on booleans only works on 1st heading click #1072

Closed
rcoundon opened this issue Nov 7, 2018 · 0 comments
Closed

Sorting on booleans only works on 1st heading click #1072

rcoundon opened this issue Nov 7, 2018 · 0 comments

Comments

@rcoundon
Copy link
Contributor

rcoundon commented Nov 7, 2018

Overview of the problem

Buefy version: [0.7.0]
Vuejs version: [2.5.17]
OS/Browser: MacOS Mojave Chrome 70.0.3538.77, Firefox 63.0.1

Description

I have a simple data set in my array that includes an email and three boolean fields.
The default sort on the table is by email and clicking the heading correctly sorts on the email field, alternating between asc and desc.
My issue is with the sorting on the boolean fields. I'll show the behaviour in a set of screenshots:

Default sort i.e. what it looks like on page load in Chrome (the Firefox behaviour is different, I'll come to that below):
initialview

Then clicking once on Field2
firstsort

Then clicking again on Field2
secondsort

As you can see the sort order doesn't change.
In Firefox, the first sort is the same:
firefoxdesc1

But when clicking on Field2 again, the order changes for for every row that doesn't have a tick (true boolean is converted to a tick icon)
firefoxasc2

The table is defined as:

<b-table
  :data="dataSet"
  :paginated="true"
  :per-page="20"
  :pagination-simple="false"
  default-sort="email">
  <template slot-scope="props">
    <b-table-column
      field="email"
      sortable
      label="Email">
      {{ props.row.email }}
    </b-table-column>
    <b-table-column
      field="dataLoaders"
      sortable
      centered
      label="Field1"
      width="60">
      <b-icon
        :icon="getIcon(props.row.dataLoaders)"
        :type="getIconColor(props.row.dataLoaders)"
        pack="fas">
      </b-icon>
    </b-table-column>
    <b-table-column
      field="omwLookup"
      sortable
      centered
      label="Field2"
      width="60">
      <b-icon
        :icon="getIcon(props.row.omwLookup)"
        :type="getIconColor(props.row.omwLookup)"
        pack="fas">
      </b-icon>
    </b-table-column>
    <b-table-column
      field="feedback"
      sortable
      centered
      label="Field3"
      width="60">
      <b-icon
        :icon="getIcon(props.row.feedback)"
        :type="getIconColor(props.row.feedback)"
        pack="fas">
      </b-icon>
    </b-table-column>
    <b-table-column
      :visible="false"
      field="key"
      sortable
      label="Key"
      width="60">
      {{ props.row.key }}
    </b-table-column>
  </template>
</b-table>

The data object looks like:

[{
    "key": "1",
    "dataLoaders": false,
    "email": "abc@abc.com",
    "feedback": false,
    "omwLookup": false
}, {
    "key": "2",
    "dataLoaders": false,
    "email": "134@234.com",
    "feedback": false,
    "omwLookup": false
}, {
    "key": "3",
    "dataLoaders": true,
    "email": "888@123.com",
    "feedback": false,
    "omwLookup": false
}, {
    "key": "4",
    "dataLoaders": true,
    "email": "222@123.com",
    "feedback": false,
    "omwLookup": true
}, {
    "key": "5",
    "dataLoaders": false,
    "email": "999@999.com",
    "feedback": false,
    "omwLookup": false
}, {
    "key": "6",
    "dataLoaders": false,
    "email": "redacted",
    "feedback": false,
    "omwLookup": true
}, {
    "key": "7",
    "dataLoaders": true,
    "email": "123@123.com",
    "feedback": true,
    "omwLookup": true
}, {
    "key": "8",
    "dataLoaders": false,
    "email": "234@234.com",
    "feedback": false,
    "omwLookup": false
}, {
    "key": "9",
    "dataLoaders": false,
    "email": "333@233.com",
    "feedback": false,
    "omwLookup": false
}, {
    "key": "10",
    "dataLoaders": false,
    "email": "test1@test.com",
    "feedback": false,
    "omwLookup": true
}]

Steps to reproduce

Follow the screenshots to reproduce. I've also tried this with the actual values i.e. {{ props.row.omwLookup }} specified as text in each b-table-column but the result is the same.
Also, I can see that the asc and desc sort events are being emitted in Vue DevTools.

Expected behavior

Expected that the sort order reverses for the table on each click

Actual behavior

As described above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant