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

Add tab item cuttoff logic. #10410

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

zutigrm
Copy link
Collaborator

@zutigrm zutigrm commented Mar 12, 2025

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

scrollContainer.style.columnGap = '2px';
}

maybeCuttOffLastTabItem();
Copy link
Collaborator Author

@zutigrm zutigrm Mar 12, 2025

Choose a reason for hiding this comment

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

Small diverging from IB, after experimenting on different screen sizes, I set the logic to run twice, double checking of previous gap worked, by first compressing the spacing, and if that didn't work, by making bigger gap, and in all cases either of these approaches will cause a cutoff in last item

Screen.Recording.2025-03-12.at.10.03.21.mov

Copy link

Build files for a33f3b9 are ready:

@@ -348,6 +416,10 @@ export default function ChipTabGroup( { allMetricItems, savedItemSlugs } ) {
// Reset the unstaged selection when selection panel is closed.
resetUnstagedSelection();
}

if ( ! isSelectionPanelOpenPrevious && isSelectionPanelOpen ) {
maybeCuttOffLastTabItem();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another diverging from IB, this had to be invoked when selection panel is opened, as on mount the panel is hidden and rectangle bound is returning 0 for all values

Copy link
Collaborator

@benbowler benbowler left a comment

Choose a reason for hiding this comment

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

Hey @zutigrm, a few small comments inline.

More broadly, from a UX perspective the difference between 2px and 20px is pretty big, in the original thread @sigal-teller said:

increase the space a little

Is it possible to achieve the same effect keeping the gap closer to 10px, perhaps adjusting between 10px and 20px as the 2px gap looks quite different to other margins within the app?

@@ -356,16 +428,34 @@ export default function ChipTabGroup( { allMetricItems, savedItemSlugs } ) {
isMobileBreakpoint,
newlyDetectedMetricsKeys,
resetUnstagedSelection,
maybeCuttOffLastTabItem,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This typo was in the IB, it should be CutOff not CuttOff throughout the PR.

visibleItems.push( index );
}
} );
const nextTabItem = tabItems[ visibleItems.length - 1 + 1 ];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't this just be:

Suggested change
const nextTabItem = tabItems[ visibleItems.length - 1 + 1 ];
const nextTabItem = tabItems[ visibleItems.length ];

@@ -224,6 +237,61 @@ export default function ChipTabGroup( { allMetricItems, savedItemSlugs } ) {
).getKeyMetricsConversionEventWidgets();
} );

const maybeCuttOffLastTabItem = useCallback( () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest you add a short code comment for this function to remind us in future why we added this logic.

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