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

Table: customSort does not work when sortMultiple is enabled #2681

Closed
Thaurin opened this issue Jul 16, 2020 · 0 comments · Fixed by #3945
Closed

Table: customSort does not work when sortMultiple is enabled #2681

Thaurin opened this issue Jul 16, 2020 · 0 comments · Fixed by #3945
Assignees

Comments

@Thaurin
Copy link

Thaurin commented Jul 16, 2020

Overview of the problem

Buefy version: [0.8.20]
Vuejs version: [2.6.11]
OS/Browser: Windows 10/Chrome 83.0.4103.116

Description

customSort function is not called when sortMultiple is enabled on a Table.

Steps to reproduce

  1. Create a Table with sortMultiple
  2. Create a column with a customSort function
  3. Try to sort that column and see if the customSort function gets called

Expected behavior

Table column should be sorted using the customSort function.

Actual behavior

The column does not get sorting at all and the row order remains unchanged. No errors are reported on the console.

@kikuomax kikuomax self-assigned this Dec 27, 2023
kikuomax added a commit to kikuomax/buefy that referenced this issue Dec 28, 2023
- Adds test cases that test sortable columns of BTable. Tests the
  following functionalities:
    - Sort single column
    - Sort multicolumns
    - Sort single column with custom sort

  Multicolumn sorting with custom sort is an issue buefy#2681
kikuomax added a commit to kikuomax/buefy that referenced this issue Dec 28, 2023
- `BTable` now uses `customSort` of each column if exists when it sorts
  multiple columns. Actual sorting is done by `multiColumnSort` function
  defined in `src/utils/helpers.js`. To support custom sort,
  `multiColumnSort` changes the format of the second parameter
  `sortingPriority` which used to accept an array of dot-separated field
  paths but now accepts an array of objects with the following fields:
    - `field`: dot-separated field path
    - `order`: sort direction:
        - 'asc' | undefined → ascending order
        - 'desc' → descending order
    - `customSort`: function to compare two field values for sorting.
      The same function given to the column definition. Natural ordering
      is used if omitted.

  As far as I checked, `multiColumnSort` is only used by `BTable`.

  Adds test cases that test multi-column sorting with custom sort.

issue buefy#2681
kikuomax added a commit that referenced this issue Dec 28, 2023
) (#3945)

* test(lib): add tests around BTable sort

- Adds test cases that test sortable columns of BTable. Tests the
  following functionalities:
    - Sort single column
    - Sort multicolumns
    - Sort single column with custom sort

* feat(lib): support multi-column sort with custom sort

- `BTable` now uses `customSort` of each column if exists when it sorts
  multiple columns. Actual sorting is done by `multiColumnSort` function
  defined in `src/utils/helpers.js`. To support custom sort,
  `multiColumnSort` changes the format of the second parameter
  `sortingPriority` which used to accept an array of dot-separated field
  paths but now accepts an array of objects with the following fields:
    - `field`: dot-separated field path
    - `order`: sort direction:
        - 'asc' | undefined → ascending order
        - 'desc' → descending order
    - `customSort`: function to compare two field values for sorting.
      The same function given to the column definition. Natural ordering
      is used if omitted.

  As far as I checked, `multiColumnSort` is only used by `BTable`.

  Adds test cases that test multi-column sorting with custom sort.
kikuomax added a commit to kikuomax/buefy that referenced this issue Jan 10, 2024
…efy#2681) (buefy#3945)

* test(lib): add tests around BTable sort

- Adds test cases that test sortable columns of BTable. Tests the
  following functionalities:
    - Sort single column
    - Sort multicolumns
    - Sort single column with custom sort

* feat(lib): support multi-column sort with custom sort

- `BTable` now uses `customSort` of each column if exists when it sorts
  multiple columns. Actual sorting is done by `multiColumnSort` function
  defined in `src/utils/helpers.js`. To support custom sort,
  `multiColumnSort` changes the format of the second parameter
  `sortingPriority` which used to accept an array of dot-separated field
  paths but now accepts an array of objects with the following fields:
    - `field`: dot-separated field path
    - `order`: sort direction:
        - 'asc' | undefined → ascending order
        - 'desc' → descending order
    - `customSort`: function to compare two field values for sorting.
      The same function given to the column definition. Natural ordering
      is used if omitted.

  As far as I checked, `multiColumnSort` is only used by `BTable`.

  Adds test cases that test multi-column sorting with custom sort.

- Includes migration to Vue 3, and Vue Test Utils v2:
    - Applies `toRaw` before testing if two columns, `column` and
      `currentSortColumn`, are indentical because they are reactive
      states. See Vue's documentation for more details:
        - https://vuejs.org/guide/essentials/reactivity-fundamentals.html#reactive-proxy-vs-original
        - https://vuejs.org/api/reactivity-advanced.html#toraw
    - Renames `propsData` → `props`
kikuomax added a commit to kikuomax/buefy that referenced this issue Feb 11, 2024
…efy#2681) (buefy#3945)

* test(lib): add tests around BTable sort

- Adds test cases that test sortable columns of BTable. Tests the
  following functionalities:
    - Sort single column
    - Sort multicolumns
    - Sort single column with custom sort

* feat(lib): support multi-column sort with custom sort

- `BTable` now uses `customSort` of each column if exists when it sorts
  multiple columns. Actual sorting is done by `multiColumnSort` function
  defined in `src/utils/helpers.js`. To support custom sort,
  `multiColumnSort` changes the format of the second parameter
  `sortingPriority` which used to accept an array of dot-separated field
  paths but now accepts an array of objects with the following fields:
    - `field`: dot-separated field path
    - `order`: sort direction:
        - 'asc' | undefined → ascending order
        - 'desc' → descending order
    - `customSort`: function to compare two field values for sorting.
      The same function given to the column definition. Natural ordering
      is used if omitted.

  As far as I checked, `multiColumnSort` is only used by `BTable`.

  Adds test cases that test multi-column sorting with custom sort.

- Includes migration to Vue 3, and Vue Test Utils v2:
    - Applies `toRaw` before testing if two columns, `column` and
      `currentSortColumn`, are indentical because they are reactive
      states. See Vue's documentation for more details:
        - https://vuejs.org/guide/essentials/reactivity-fundamentals.html#reactive-proxy-vs-original
        - https://vuejs.org/api/reactivity-advanced.html#toraw
    - Renames `propsData` → `props`
kikuomax added a commit to ntohq/buefy-next that referenced this issue Feb 12, 2024
…efy#2681) (buefy#3945)

* test(lib): add tests around BTable sort

- Adds test cases that test sortable columns of BTable. Tests the
  following functionalities:
    - Sort single column
    - Sort multicolumns
    - Sort single column with custom sort

* feat(lib): support multi-column sort with custom sort

- `BTable` now uses `customSort` of each column if exists when it sorts
  multiple columns. Actual sorting is done by `multiColumnSort` function
  defined in `src/utils/helpers.js`. To support custom sort,
  `multiColumnSort` changes the format of the second parameter
  `sortingPriority` which used to accept an array of dot-separated field
  paths but now accepts an array of objects with the following fields:
    - `field`: dot-separated field path
    - `order`: sort direction:
        - 'asc' | undefined → ascending order
        - 'desc' → descending order
    - `customSort`: function to compare two field values for sorting.
      The same function given to the column definition. Natural ordering
      is used if omitted.

  As far as I checked, `multiColumnSort` is only used by `BTable`.

  Adds test cases that test multi-column sorting with custom sort.

- Includes migration to Vue 3, and Vue Test Utils v2:
    - Applies `toRaw` before testing if two columns, `column` and
      `currentSortColumn`, are indentical because they are reactive
      states. See Vue's documentation for more details:
        - https://vuejs.org/guide/essentials/reactivity-fundamentals.html#reactive-proxy-vs-original
        - https://vuejs.org/api/reactivity-advanced.html#toraw
    - Renames `propsData` → `props`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Completed ✅
Development

Successfully merging a pull request may close this issue.

3 participants