Skip to content

feat(Nav): performance improvements#55

Merged
dlabaj merged 4 commits intopatternfly:mainfrom
kmcfaul:nav-improvements
May 14, 2025
Merged

feat(Nav): performance improvements#55
dlabaj merged 4 commits intopatternfly:mainfrom
kmcfaul:nav-improvements

Conversation

@kmcfaul
Copy link
Collaborator

@kmcfaul kmcfaul commented May 12, 2025

  • Moves raw entry data manipulation out of the Navigation components (creating nav entry data, sorting & deduping sections & entries)
  • Removes some tests for now as the above isn't inside the Nav anymore. I may look at refactoring some of the logic of the deduping / sorting into a util file which we can test, or see if we can test the code fenced block somehow.

Open question/thoughts:
I think we can probably clean up the data structure that Navigation gets a bit more, the TextContentEntry probably doesn't need the data.section now because that info is in the Record, and it doesn't have to match the entry data structure (so we can probably move away from id, data: {id} style).

@kmcfaul kmcfaul changed the title feat(Nav): WIP performance feat(Nav): performance improvements May 13, 2025
]
}

navData[section] = navEntries;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not 100% sure, but I think because the sections were previously sorted it maintains that order as it gets added to the data (because it is ordered by insertion order). LMK if I'm incorrect about this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think insertion ordered isn't guaranteed to be preserved in all browsers, but I'm also not 100% sure.

I wonder if we should form and pass the nav data as an array rather than as an object since in the nav we just map through the entries anyways.

@dlabaj dlabaj merged commit dceafe9 into patternfly:main May 14, 2025
1 check passed
@github-actions
Copy link

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

)

const sortedSections = [...orderedSections, ...unorderedSections.sort()]
sortedSections.map((section) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels kind of weird that we're doing a map here if we aren't used the mapped result? Or am I misunderstanding something.

]
}

navData[section] = navEntries;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think insertion ordered isn't guaranteed to be preserved in all browsers, but I'm also not 100% sure.

I wonder if we should form and pass the nav data as an array rather than as an object since in the nav we just map through the entries anyways.

@wise-king-sullyman
Copy link
Contributor

Oh I see this was merged between before I finished the review 😬

@kmcfaul kmcfaul linked an issue May 21, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance Issues

3 participants