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 issues with descendants and allDescendants #3728

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Conversation

lbwexler
Copy link
Member

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

@lbwexler lbwexler requested a review from haynesjm42 July 21, 2024 01:00
@lbwexler lbwexler linked an issue Jul 21, 2024 that may be closed by this pull request
Copy link
Member

@amcclain amcclain left a comment

Choose a reason for hiding this comment

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

Thanks for the close look at this one + the deeper fix

@@ -7,6 +7,10 @@
* Enhanced `markdown` component to support the underlying `components` prop from
`react-markdown`. Use this prop to customize markdown rendering.

### 🐞 Bug Fixes
* The `Record.descendants` and `Record.allDescendants` getters were incorrectly returning the
record itself. This has been fixed.
Copy link
Member

Choose a reason for hiding this comment

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

Ah interesting - there is a chance there is some code out there that was depending on the prior behavior (intentionally or not), but hard to argue that it was correct. This looks like the right choice / fix to me.

Copy link
Member

Choose a reason for hiding this comment

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

Agree that this change makes sense - previous behavior was definitely confusing - I vaguely remember this from when we were re-working these methods way back but can't remember why we included the record in the list of descendants

children.forEach(child => this.gatherDescendantIds(child.id, idSet));
this.childrenMap.get(id)?.forEach(child => {
if (!idSet.has(child.id)) {
// paranoia? did we encounter loops?
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this came in a while ago with a big refactor that introduced many of these recordset APIs - doesn't look like a response to a particular bug or use case.

https://github.com/xh/hoist-react/pull/1082/files

(FWIW - I'd still vote to carry it forward - will cop to a certain amount of paranoia in these classes myself)

@@ -7,6 +7,10 @@
* Enhanced `markdown` component to support the underlying `components` prop from
`react-markdown`. Use this prop to customize markdown rendering.

### 🐞 Bug Fixes
* The `Record.descendants` and `Record.allDescendants` getters were incorrectly returning the
record itself. This has been fixed.
Copy link
Member

Choose a reason for hiding this comment

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

Agree that this change makes sense - previous behavior was definitely confusing - I vaguely remember this from when we were re-working these methods way back but can't remember why we included the record in the list of descendants

@lbwexler lbwexler merged commit d96cd99 into develop Jul 22, 2024
2 checks passed
@lbwexler lbwexler deleted the getDescendantsFix branch July 22, 2024 13:34
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.

Summary StoreRecord.descendants/allDescendants return [undefined]
3 participants