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

Allow deselecting a sorted column in EuiTable #1113

Closed
cjcenizal opened this issue Aug 10, 2018 · 4 comments
Closed

Allow deselecting a sorted column in EuiTable #1113

cjcenizal opened this issue Aug 10, 2018 · 4 comments

Comments

@cjcenizal
Copy link
Contributor

Per elastic/kibana#14687 (comment), we want the ability to display rows inside of a table in the order in which the API provided them.

In terms of UX, I think we can accomplish this by allowing the user to click on a column to cycle through sorting on that column, sorting on that column reversed, and then deselecting it to use the default order of the items.

@nreese
Copy link
Contributor

nreese commented Aug 11, 2018

@cjcenizal Here is how we have implemented deselecting sort in the dashboard app with EuiBasicTable. It would be really nice to have native support so we don't have to duplicate this logic everywhere.

https://github.com/elastic/kibana/blob/master/src/core_plugins/kibana/public/dashboard/listing/dashboard_listing.js#L146

  onTableChange = ({ page, sort = {} }) => {
    const {
      index: pageIndex,
      size: pageSize,
    } = page;

    let {
      field: sortField,
      direction: sortDirection,
    } = sort;

    // 3rd sorting state that is not captured by sort - native order (no sort)
    // when switching from desc to asc for the same field - use native order
    if (this.state.sortField === sortField
      && this.state.sortDirection === 'desc'
      && sortDirection === 'asc') {
      sortField = null;
      sortDirection = null;
    }

    this.setState({
      page: pageIndex,
      perPage: pageSize,
      sortField,
      sortDirection,
    });
  }

@chandlerprall
Copy link
Contributor

@snide @cchaos do other table implementations have a common UX pattern for deselecting the sort column?

@thompsongl
Copy link
Contributor

Just noticed this issue.
Fairly certain #1591 added the requested functionality and would be available >=9.0.0

@snide
Copy link
Contributor

snide commented Apr 10, 2019

Yep. Let's close it out. Feel free to open if that is not the case.

@snide snide closed this as completed Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants