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

[TableListView] Fix regression when resetting search #162034

Merged
merged 9 commits into from
Jul 18, 2023

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Jul 17, 2023

In #160650 we introduced a regression. When clearing a search request that didn't contain any result we were taking back to the empty prompt.

I reversed the changed in the PR to fix it and I added tests to prevent future regression for this.

@nreese Strangely enough I am not able to reproduce the issue you fixed after reverting your changes. I switched to "slow 3g" network as per your comment here #148557 (comment) but still could not reproduce the UI flashing issue.

I wonder if the fix needed from your PR was adding this useCallback (https://github.com/elastic/kibana/pull/160650/files#diff-7b0b3bede33bed7e2f5f7095697650d92c8ec131e29b9fccc384cacafad84689R84-R88)

[EDIT] I manage to reproduce. It only occurred when there are no items in the table.

Other fix

I also fixed the flaky test (#160178) that Nathan had fixed in his PR by making sure that once we detect that there no items we don't remove the empty prompt.

"Glitch" that has been fixed

Notice how we go from "No files found" (empty prompt) --> "Table" (no files match your search) --> "No files found".

table-list-view-refresh-bug

Fixes #161288
Fixes #160178

@sebelga sebelga self-assigned this Jul 17, 2023
@sebelga sebelga added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) Feature:Content Management User generated content (saved objects) management Component:TableListView labels Jul 17, 2023
@sebelga sebelga force-pushed the fix-table-list-view-search-reset branch from d909e54 to 2d6647a Compare July 17, 2023 11:24
@sebelga sebelga marked this pull request as ready for review July 17, 2023 11:24
@sebelga sebelga requested a review from a team as a code owner July 17, 2023 11:24
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@sebelga sebelga requested review from nreese and Dosant July 17, 2023 11:24
@sebelga sebelga marked this pull request as draft July 17, 2023 13:15
@sebelga
Copy link
Contributor Author

sebelga commented Jul 17, 2023

Sorry for the ping @Dosant and @nreese. I put the PR back to draft and fix CI first.

@sebelga sebelga force-pushed the fix-table-list-view-search-reset branch from 2d6647a to a27cbf8 Compare July 17, 2023 14:46
@nreese
Copy link
Contributor

nreese commented Jul 17, 2023

@nreese Strangely enough I am not able to reproduce the issue you fixed after reverting your changes. I switched to "slow 3g" network as per your comment here #148557 (comment) but still could not reproduce the UI flashing issue.

I am able to see flashing UI in this PR. To view, open visualize listing page when you have no visualization saved objects. In the empty case, the table should never be displayed.

Screen.Recording.2023-07-17.at.8.53.05.AM.mov

@nreese
Copy link
Contributor

nreese commented Jul 17, 2023

Would it be possible to remove fetchItems from useDebounce dependency check? And instead only call fetchItems when the search changes and not dependency chain.

The problem is that fetchItems is called twice when the page loads.

  1. Once when page loads
  2. A second time, because the first call to fetchItems dispatches onFetchItemsSuccess. This causes the parent component to pass in a new version of onFetchSuccess since calling onFetchSuccess changes state hasInitialFetchReturned
    const onFetchSuccess = useCallback(() => {
        if (!hasInitialFetchReturned) {
          setHasInitialFetchReturned(true);
        }
      }, [hasInitialFetchReturned]);
    

@sebelga
Copy link
Contributor Author

sebelga commented Jul 17, 2023

I am able to see flashing UI in this PR.

Can you retest now. I fixed it here 2a6f300

Would it be possible to remove fetchItems from useDebounce dependency check?

No because that would open the door for other future regression. We want to fetch the items any time any of the dependency change.

const onFetchSuccess = useCallback(() => {
    if (!hasInitialFetchReturned) {
      setHasInitialFetchReturned(true);
    }
  }, [hasInitialFetchReturned]);

That was a mistake from Andrew. The function that update the state has the state as a dependency. Usually a source of infinite re-render. I changed it here 07a237a

totalItems: 0,
hasInitialFetchReturned: false,
isFetchingItems: false,
isFetchingItems: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you defaulting to isFetchingItems is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the state when he table mount: it fetches the items.

We initially had an useEffect + useDebounce. You correctly removed the effect (#159507) so we only have one of the 2 but we need to wait 300ms before having this state set to true.

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

LGTM
code review, tested in chrome

@stratoula
Copy link
Contributor

Thanx @sebelga

The only bug I found is also depicted on the failing graph test.
When I have some items in the listing page and I delete them all, I expect to see the empty listing page. On the contrary I see the No {SO type} matched your search. screen.

image

@sebelga sebelga marked this pull request as ready for review July 18, 2023 09:34
@sebelga
Copy link
Contributor Author

sebelga commented Jul 18, 2023

Thanks for the review @nreese and @stratoula! 👍

The only bug I found is also depicted on the failing graph test.

Yes indeed, good catch. I fixed it in 4d57f17

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

This looks fantastic! Thanx @sebelga ❤️

Tested different scenarios and everything works as expected 🥇

Copy link
Contributor

@Dosant Dosant left a comment

Choose a reason for hiding this comment

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

tested, works well

@sebelga sebelga enabled auto-merge (squash) July 18, 2023 10:42
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/content-management-table-list-view-table 41 40 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 355.6KB 355.7KB +50.0B
eventAnnotation 140.4KB 140.5KB +58.0B
filesManagement 89.2KB 89.2KB +51.0B
graph 458.3KB 458.4KB +51.0B
maps 2.8MB 2.8MB +51.0B
visualizations 262.4KB 262.5KB +84.0B
total +345.0B

History

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

cc @sebelga

@sebelga sebelga merged commit c6deb25 into elastic:main Jul 18, 2023
@kibanamachine kibanamachine added v8.10.0 backport:skip This commit does not require backporting labels Jul 18, 2023
@sebelga sebelga deleted the fix-table-list-view-search-reset branch July 18, 2023 13:11
@drewdaemon
Copy link
Contributor

Does it make sense to backport this for 8.9?

@nreese
Copy link
Contributor

nreese commented Jul 18, 2023

Does it make sense to backport this for 8.9?

I would vote yes, since #160650 is in 8.9.0

@sebelga
Copy link
Contributor Author

sebelga commented Jul 18, 2023

I would vote yes, since #160650 is in 8.9.0

Is there a label we can add now or do I need to use the script?

@stratoula
Copy link
Contributor

You need to use the script unfortunately afaik

@sebelga sebelga added the v8.9.1 label Jul 18, 2023
@drewdaemon
Copy link
Contributor

For the record, @pheyos mentioned that adding the backport:last-minor label works even after merge. It didn't seem to work for me, but has worked for others.

Whatever gets the job done 👍

@sebelga sebelga added backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) and removed backport:skip This commit does not require backporting v8.9.1 labels Jul 19, 2023
sebelga added a commit to sebelga/kibana that referenced this pull request Jul 19, 2023
@sebelga
Copy link
Contributor Author

sebelga commented Jul 19, 2023

💚 All backports created successfully

Status Branch Result
8.9

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.9

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jul 19, 2023
…162211)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[TableListView] Fix regression when resetting search
(#162034)](#162034)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sébastien
Loix","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-07-18T11:47:01Z","message":"[TableListView]
Fix regression when resetting search
(#162034)","sha":"c6deb252b2a2830ad1d689c476517f783247206b","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:SharedUX","Feature:Content
Management","backport:prev-minor","Component:TableListView","v8.10.0"],"number":162034,"url":"https://github.com/elastic/kibana/pull/162034","mergeCommit":{"message":"[TableListView]
Fix regression when resetting search
(#162034)","sha":"c6deb252b2a2830ad1d689c476517f783247206b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/162034","number":162034,"mergeCommit":{"message":"[TableListView]
Fix regression when resetting search
(#162034)","sha":"c6deb252b2a2830ad1d689c476517f783247206b"}}]}]
BACKPORT-->

Co-authored-by: Sébastien Loix <[email protected]>
ThomThomson pushed a commit to ThomThomson/kibana that referenced this pull request Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) bug Fixes for quality problems that affect the customer experience Component:TableListView Feature:Content Management User generated content (saved objects) management release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.9.0 v8.10.0
Projects
None yet
8 participants