-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Explore Vis] Fix table visualiztion issues #10754
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
[Explore Vis] Fix table visualiztion issues #10754
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10754 +/- ##
==========================================
+ Coverage 60.47% 60.50% +0.02%
==========================================
Files 4484 4485 +1
Lines 120115 120185 +70
Branches 19892 19910 +18
==========================================
+ Hits 72641 72719 +78
+ Misses 42431 42426 -5
+ Partials 5043 5040 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
} | ||
}, [styleOptions?.showColumnFilter]); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you leave a comment on this useEffect
to describe the logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this just a replacement by new columns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lunalzm How do you reproduce the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hailong-am @lunalzm I removed this useEffect
, and pushed a commit that fix the column visibility issue from the root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just read the comment for this method and didn't read the logic fully, so i think it just a replacement by new columns. There have different property in VisColumn
interface, i see we are using id
, name
and column
, not sure what's the difference.
const sortedColumns = useMemo(() => [...columns].sort((a, b) => a.id - b.id), [columns]);
const newColumnIds = sortedColumns.map(({ column }) => column);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue sometimes happens when I run a new query or refresh the page. Some columns get hidden by default.
Screen.Recording.2025-10-21.at.16.54.54.mov
Signed-off-by: Luna Liu <[email protected]>
Signed-off-by: Luna Liu <[email protected]>
f1b57ff
to
3a9c07d
Compare
...(visualizationData?.dateColumns ?? []), | ||
]; | ||
|
||
return allColumns.sort((a, b) => a.id - b.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also check explore_embeddable.tsx
to see if the same logic should apply there? or perhaps move this logic to table_vis
component?
…embeddables Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
|
||
export const TableVis = React.memo( | ||
({ rows, columns, styleOptions, pageSizeOptions, showStyleSelector }: TableVisProps) => { | ||
const sortedColumns = useMemo(() => columns.sort((a, b) => a.id - b.id), [columns]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort will update the original columns, I prefer to construct a new array for sorting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, I will update
rows={visualizationData.transformedData ?? []} | ||
columns={columns} | ||
/> | ||
<TableVis styleOptions={visConfig.styles as TableChartStyle} rows={rows} columns={columns} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to rows
which is defined as this, should be the same
const rows = useMemo(() => {
return visualizationData?.transformedData ?? [];
}, [visualizationData?.transformedData]);
Signed-off-by: Yulong Ruan <[email protected]>
// If there are common fields, preserve existing visible columns and add any new ones | ||
useEffect(() => { | ||
const currentFieldNames = sortedColumns.map(({ name }) => name); | ||
const prevFieldNames = prevFieldNamesRef.current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to delete this ref, can we calculate the new columns based prevVisibleColumns
in setVisibleColumns
callback and sortedColumns
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall implementation has changed, this useEffect
no longer exists now
|
||
const renderFooterCellValue = useCallback( | ||
({ columnId, setCellProps }: EuiDataGridCellValueElementProps) => { | ||
const alignment = styleOptions?.globalAlignment || 'auto'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be left
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
|
||
export const TableVis = React.memo( | ||
({ rows, columns, styleOptions, pageSizeOptions, showStyleSelector }: TableVisProps) => { | ||
const sortedColumns = useMemo(() => [...columns].sort((a, b) => a.id - b.id), [columns]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can make the columns is ordered in props in parent component, that could reduce the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component is used at different places, having the sorting here is to avoid having the same logic at multiple places
Checked the failed test is unrelated, merging now |
Description
This PR addresses several critical issues with table visualizations in the Explore plugin:
left
to mitigate the table cell text move issueThe fixes ensure that table visualizations now correctly respect the field order specified in queries and properly manage column visibility across query executions.
Screenshot
Field Order
Before
After
Column Visibility
Before
After
Testing the changes
SOURCE = opensearch_dashboards_sample_data_logs | FIELDS @timestamp, extension, bytes, agent
- Verify fields appear in order: @timestamp → extension → bytes → agent
- Previously would show: bytes → @timestamp → extension → agent
SOURCE = opensearch_dashboards_sample_data_logs | FIELDS bytes, memory, referer, url, agent
- Verify all fields are hidden
Changelog
Check List
yarn test:jest
yarn test:jest_integration