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 show page navigation bugs #9199

Merged
merged 3 commits into from
Dec 23, 2024
Merged

Fix show page navigation bugs #9199

merged 3 commits into from
Dec 23, 2024

Conversation

lucasbordeau
Copy link
Contributor

@lucasbordeau lucasbordeau commented Dec 23, 2024

Fixes total count bug that was -1 the total count
Fixes a bug when trying to go from first to last or the other way around
Fixes a React array key bug

Follow-up issue (non critical) : #9197

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR enhances the show page navigation system by improving key prop stability in action menu buttons and refining pagination logic for better edge case handling.

  • Added unique entry.key prop for Button/IconButton components in /packages/twenty-front/src/modules/action-menu/components/RecordShowActionMenuButtons.tsx replacing array indices
  • Improved pagination logic in /packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPagePagination.ts with explicit first/last record checks and cache availability validation
  • Fixed total count calculation by including current record in /packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPagePagination.ts

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +133 to +146
if (isFirstRecord) {
if (cacheIsAvailableForNavigation) {
const lastRecordIdFromCache =
recordIdsInCache[recordIdsInCache.length - 1];

navigate(
buildShowPageURL(
objectNameSingular,
lastRecordIdFromCache,
viewIdQueryParam,
),
);
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: potential race condition if cache becomes unavailable between check and navigation

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM

const navigateToNextRecord = () => {
if (isDefined(recordAfter)) {
if (isLastRecord) {
if (cacheIsAvailableForNavigation) {
Copy link
Member

Choose a reason for hiding this comment

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

redundant if?

@Weiko Weiko merged commit 691fbbe into main Dec 23, 2024
22 checks passed
@Weiko Weiko deleted the fix/show-page-nav-bar branch December 23, 2024 13:24
samyakpiya pushed a commit to samyakpiya/twenty that referenced this pull request Dec 28, 2024
Fixes total count bug that was -1 the total count
Fixes a bug when trying to go from first to last or the other way around
Fixes a React array key bug

Follow-up issue (non critical) :
twentyhq#9197
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