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

Query Browser: Make SeriesButton key always unique #2495

Conversation

kyoto
Copy link
Member

@kyoto kyoto commented Aug 27, 2019

Unfortunately, [index, metric] appears to not be unique enough, causing the UI to occasionally seize up when rendering the query results table.

\cc @spadgett

@openshift-ci-robot openshift-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. component/core Related to console core functionality component/monitoring Related to monitoring approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 27, 2019
@kyoto
Copy link
Member Author

kyoto commented Aug 27, 2019

/retest

1 similar comment
@kyoto
Copy link
Member Author

kyoto commented Aug 27, 2019

/retest

@@ -518,7 +518,7 @@ const QueryTable_: React.FC<QueryTableProps> = ({index, isEnabled, isExpanded, q
rowMapper = ({metric, value}) => [
// TableBody's shouldComponentUpdate seems to struggle with SeriesButton, so add a unique key to help TableBody
// determine when it should update
{title: <SeriesButton index={index} key={JSON.stringify([index, metric])} labels={metric} />},
{title: <SeriesButton index={index} key={_.uniqueId()} labels={metric} />},
Copy link
Member

Choose a reason for hiding this comment

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

Is this a bug with the PF4 table?

cc @priley86

Copy link
Member

Choose a reason for hiding this comment

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

@priley86 For context, we're seeing cases where the table isn't re-rending. This is a hack to make sure it always re-renders, but I'd like to track this down further if it might be a problem in Patternfly.

Copy link
Contributor

Choose a reason for hiding this comment

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

hey @spadgett - was having a conversation w/ Andy about this yesterday. Here's my current thoughts...

you are correct that you would need to pass a prop on the row to force re-rendering to occur. This is sort of a “blind optimization” on our part - we check if any row props have changed to try to prevent all rows from re-rendering : https://github.com/patternfly/patternfly-react/blob/547c644e68fb9f36d068aab9427a7ef533ed1cf9/packages/patternfly-4/react-table/src/components/Table/base/body-row.tsx#L44

You can override the row’s shouldComponentUpdate method by using a RowWrapper like this on your Table definition: https://reactabular.js.org/#/table/overriding-should-component-update

Or you can just provide the key with unique ID like you have it (causing re-render of children to occur each time).

If you do not feel like this resolves it, please feel free to suggest an alternative though.

Copy link
Contributor

@priley86 priley86 Aug 27, 2019

Choose a reason for hiding this comment

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

Basically, this is an attempt to optimize row rendering. If you think it a poor optimization, it can certainly be modified or removed. Let me know!

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

Let’s fix the immediate problem for 4.2 and open a tech debt issue to find a better solution

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kyoto, spadgett

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit e8994de into openshift:master Aug 28, 2019
@kyoto kyoto deleted the query-browser-fix-series-button-key branch August 28, 2019 03:30
@spadgett spadgett added this to the v4.2 milestone Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/monitoring Related to monitoring lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants