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

refactor(ActionBar): implement useOverflowItems hook in ActionBar #6775

Merged
merged 46 commits into from
Feb 12, 2025

Conversation

makafsal
Copy link
Member

Closes #6720

What did you change?

  1. Implemented useOverflowItems hook in ActionBar
  2. Fixed OverflowMenu issue
  3. Fixed Actiobar width issue PageHeader

How did you test and verify your work?

Storybook
yarn test

@makafsal makafsal requested a review from a team as a code owner January 28, 2025 14:12
@makafsal makafsal requested review from davidmenendez and AlexanderMelox and removed request for a team January 28, 2025 14:12
Copy link

netlify bot commented Jan 28, 2025

Deploy Preview for carbon-for-ibm-products ready!

Name Link
🔨 Latest commit 5989b8e
🔍 Latest deploy log https://app.netlify.com/sites/carbon-for-ibm-products/deploys/67ab2d886931bf0008691730
😎 Deploy Preview https://deploy-preview-6775--carbon-for-ibm-products.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 28, 2025

Deploy Preview for ibm-products-web-components ready!

Name Link
🔨 Latest commit 5989b8e
🔍 Latest deploy log https://app.netlify.com/sites/ibm-products-web-components/deploys/67ab2d88ace7c60008b051d7
😎 Deploy Preview https://deploy-preview-6775--ibm-products-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@davidmenendez davidmenendez left a comment

Choose a reason for hiding this comment

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

Screen.Recording.2025-01-29.at.8.43.37.AM.mov

looks like there's still something not quite right here. i'll take a look and help you to identify what's causing this stutter

also tests are failling

@makafsal
Copy link
Member Author

makafsal commented Feb 7, 2025

i figured out the solution to dealing with the offset ref not being defined. instead of passing that ref to ActionBarOverflowItems just wrap that component with a div that has the ref.

<div className="hidden-items" ref={offsetRef}>
  {hiddenItems && hiddenItems?.length > 0 && (
    ...
  )}
</div>

this should ensure the offset it set correctly and will make the hidden item sizing unnecessary.

Screen.Recording.2025-02-06.at.4.02.43.PM.mov

I've tested this approach, but it is not working as expected in most of the cases.

Screen.Recording.2025-02-07.at.12.36.48.PM.mov

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 87.27273% with 7 lines in your changes missing coverage. Please review.

Project coverage is 81.50%. Comparing base (a9a4285) to head (5989b8e).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6775      +/-   ##
==========================================
+ Coverage   81.49%   81.50%   +0.01%     
==========================================
  Files         399      399              
  Lines       12978    12991      +13     
  Branches     4270     4282      +12     
==========================================
+ Hits        10576    10588      +12     
- Misses       2402     2403       +1     
Components Coverage Δ
ibm-products ∅ <ø> (∅)
ibm-products-web-components ∅ <ø> (∅)

Copy link
Contributor

@davidmenendez davidmenendez left a comment

Choose a reason for hiding this comment

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

i think a bit more than what was needed was added in the last commit. i don't see the added benefit to the additional effects or refs. i think the only thing that was needed to fix the issue with the offset not being initially calculated when not present. just the inclusion of that example code i sent on friday

  const offsetRefHolder = useRef<number | null>(null);

  const handleResize = () => {
    if (containerRef.current) {
      const offset = offsetRef?.current?.offsetWidth || 0;
      if (offset && !offsetRefHolder.current) {
        offsetRefHolder.current = offset;
      }
      const newMax =
        containerRef.current.offsetWidth - (offsetRefHolder.current || 0);
      setMaxWidth(newMax);
    }
  };

if i'm missing something with the new implementation please let me know.

}
}, [getVisibleItems, onChange, remainingWidth, requiredWidth]);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think that this effect is necessary. i don't think we need to include these new refs for hidden and visible items. if we can calculate these things on the fly then there's no real need to store them anywhere unless we're trying to cache the value.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, I've given a second look and refactored that.

Copy link
Contributor

@davidmenendez davidmenendez left a comment

Choose a reason for hiding this comment

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

ok looks good! i think we're ready to move on

Copy link
Contributor

@devadula-nandan devadula-nandan left a comment

Choose a reason for hiding this comment

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

LGTM

@makafsal makafsal added this pull request to the merge queue Feb 12, 2025
Merged via the queue into carbon-design-system:main with commit f7609f5 Feb 12, 2025
32 checks passed
@makafsal makafsal deleted the task-6720 branch February 12, 2025 09:06
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.

Refactor ActionBar to use useOverflowItems
3 participants