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: Collapsed state between redraws #703

Merged

Conversation

BeyondEvil
Copy link
Contributor

No description provided.

@BeyondEvil BeyondEvil force-pushed the beyondevil/store-collapsed-state branch from 8b3be90 to 18c7030 Compare July 28, 2023 12:00
@BeyondEvil BeyondEvil marked this pull request as ready for review July 28, 2023 12:00
@BeyondEvil BeyondEvil merged commit af4c653 into pytest-dev:master Jul 28, 2023
@BeyondEvil BeyondEvil deleted the beyondevil/store-collapsed-state branch July 28, 2023 15:28
const tests = Object.values(data.tests).flat().map((test, index) => {
const collapsed = collapsedCategories.includes(test.result.toLowerCase())
const id = `test_${index}`
if (collapsed) {
collapsedIds.push(id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd avoid updating the collapsedIds collection in the map.
Instead I would do it after the construction of collapsed collection:
const collapsedIds = collapsed.map(({id}) => id)

Copy link
Collaborator

Choose a reason for hiding this comment

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

or even better:
setCollapsedIds(collapsed.map(({id}) => id))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually had it that way at first. But thought it was better to not do two iterations over the same collection.

@@ -47,6 +53,10 @@ class DataManager {
get environment() {
return this.renderData.environment
}

get initialSort() {
return this.data.initialSort
Copy link
Collaborator

Choose a reason for hiding this comment

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

return [...this.data.initialSort]

This prevents data.initialSort from becoming compromised by being updated by reference.

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.

2 participants