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

fix: Preserve tree expansion state #22347

Conversation

mike-plummer
Copy link
Contributor

Video: https://cypressio.slack.com/archives/C035VB3HVAL/p1655219943591069

Addressing a reactivity issue we currently have in our useCollapsibleTree usage. In ACI, row data is loaded as the user scrolls and periodically in the background - these fetches flow back through GQL and present as a "new" list of specs (even though it's the same specs, just with new deeply-nested content) which triggers the tree data to get rebuilt. This manifests as the tree state re-setting on scroll and is likely contributing to some of the scroll lagginess we're seeing.

Without reworking the implementation which would impact multiple UI areas at present this is a next-best: incorporate an external cache that can be used to persist the expansion state of the directories so that when the tree does get rebuilt the state is maintained. This cache is then cleared when the user searches or changes the list of specs because we want the directories to expand in those situations to match 10.1.0 behavior.

User facing changelog

Additional details

I wasn't able to find a good way to test this in CT; since SpecList is using mountFragment and GQL I couldn't find a way to mutate the GQL data and trigger a reactive data update within a single mount cycle. If someone knows how to do this I'd love to learn how

Steps to test

  1. Open E2E mode with a project that has at least one recorded run in the cloud (preferably one with
  2. Log in if not already
  3. Observe latest run data begin to load
  4. Collapse a directory and scroll down
  5. Observe directory remains collapsed as lower rows scroll into viewport and load cloud data
    • Current behavior would result in directory resetting to expanded

How has the user experience changed?

SpecsList directory expansion state should persist as ACI data is loaded during scroll

PR Tasks

  • Have tests been added/updated?
  • [na] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 15, 2022

Thanks for taking the time to open a PR!

Copy link
Contributor

@MuazOthman MuazOthman left a comment

Choose a reason for hiding this comment

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

Looks good and functional. I defer to @marktnoonan to advise in terms of performance and memory use, but it seems to have minimal memory footprint using a sparse map.

@@ -92,7 +103,7 @@ function sortTree<T extends RawNode<T>> (tree: T) {
}

export function useCollapsibleTree <T extends RawNode<T>> (tree: T, options: UseCollapsibleTreeOptions = {}) {
options.expandInitially = options.expandInitially || true
options.expandInitially = options.expandInitially ?? true
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

@cypress
Copy link

cypress bot commented Jun 15, 2022



Test summary

37553 0 454 0Flakiness 3


Run details

Project cypress
Status Passed
Commit 75a696b
Started Jun 15, 2022 9:53 PM
Ended Jun 15, 2022 10:09 PM
Duration 16:49 💡
OS Linux Debian - 10.11
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

next.cy.ts Flakiness
1 Working with next-12.1.6 > should detect new spec
cypress/proxy-logging.cy.ts Flakiness
1 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second
2 Proxy Logging > request logging > xhr log has response body/status code when xhr response is logged second

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Nice fix with minimal changes. The virtual list feels kind of bleh, I think we need to rethink this approach. If we do away with highlighting characters during fuzzy search I think we can vastly cut down on the number of DOM nodes and avoid the need virtualize it, but another battle for another day.

Will wait for a review from @marktnoonan, he's more across the UI side of app than me.

@MuazOthman MuazOthman requested a review from ZachJW34 June 16, 2022 23:56
Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

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

Forgot to drop this approval before I logged off yesterday, but this looks good to me. The old behavior was really noticeable, especially when even collapsing a row would cause new items to render, re-expanding the row you just collapsed. Good solution.

@mike-plummer mike-plummer merged commit 616510a into muaz/CLOUD-577-spec-list-display-latest-runs Jun 21, 2022
@mike-plummer mike-plummer deleted the mikep/CLOUD-577-cache-tree-expansion-state branch June 21, 2022 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants