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

[Lens] Fix table sorting bug #74902

Merged
merged 2 commits into from
Aug 14, 2020

Conversation

wylieconlon
Copy link
Contributor

The table configuration should always be matched in the table expression, which is not happening for in several cases.

Steps to reproduce:

  1. Use the chart switcher and go to an empty datatable
  2. Drag the Records field and you should get a suggestion with 2 columns
  3. Drag a new string field into the empty dimension labeled "Drop a field here"
  4. The order shown in the table will not match the order shown on the right side

The fix for this issue should be to use the same logic in both getConfiguration and toExpression, which is to sort the table columns by the datasource order using this snippet from getConfiguration.

    const datasource = frame.datasourceLayers[layer.layerId];
    const originalOrder = datasource.getTableSpec().map(({ columnId }) => columnId);
    // When we add a column it could be empty, and therefore have no order
    const sortedColumns = Array.from(new Set(originalOrder.concat(layer.columns)));

This small change should fix the bug and guarantee consistent order.

GIF of the fix in action:

Kapture 2020-08-12 at 16 29 01

Fixes #74900

Checklist

@wylieconlon wylieconlon added release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 Feature:Lens v7.10.0 labels Aug 12, 2020
@wylieconlon wylieconlon requested review from flash1293, mbondyra and a team August 12, 2020 20:33
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

page load bundle size

id value diff baseline
lens 858.1KB +187.0B 858.0KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in chrome, works as expected. LGTM

@wylieconlon wylieconlon merged commit ec5112b into elastic:master Aug 14, 2020
@wylieconlon wylieconlon deleted the lens/fix-table-sorting branch August 14, 2020 14:54
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 14, 2020
* master:
  Fix bug on TopN weird behavior with zero values (elastic#74942)
  [Lens] Fix table sorting bug (elastic#74902)
  [SECURITY_SOLUTION] Retry on ingest setup (elastic#75000)
  [file upload] lazy load to reduce page load size (elastic#74967)
  Drilldowns for TSVB / Vega / Timelion (elastic#74848)
  [EventLog] Populate alert instances view with event log data (elastic#68437)
  [UiActions] pass trigger into action execution context (elastic#74363)
wylieconlon pushed a commit that referenced this pull request Aug 14, 2020
* [Lens] Fix table sorting bug

* Fix types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Bugs in table rendering caused by toExpression function
4 participants