Skip to content

[Lens] Fix table sorting bug#74902

Merged
wylieconlon merged 2 commits intoelastic:masterfrom
wylieconlon:lens/fix-table-sorting
Aug 14, 2020
Merged

[Lens] Fix table sorting bug#74902
wylieconlon merged 2 commits intoelastic:masterfrom
wylieconlon:lens/fix-table-sorting

Conversation

@wylieconlon
Copy link
Copy Markdown
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 Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.0.0 Feature:Lens v7.10.0 labels Aug 12, 2020
@wylieconlon wylieconlon requested review from a team, flash1293 and mbondyra August 12, 2020 20:33
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@kibanamachine
Copy link
Copy Markdown
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
Copy Markdown
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 Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// 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