fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Pivot: Support overflowing pivots

Open quanglefed opened this issue 8 years ago • 33 comments

Hi all,

I think this would be nice. Do we have any plan to handle Pivots are overflowed.?

Thank in advance, Quang Le

quanglefed avatar Feb 22 '18 05:02 quanglefed

@betrue-final-final is this something we have a design for, or something we want to support? If there is a different pattern we should be following instead, that's fine too.

micahgodbolt avatar Dec 27 '18 18:12 micahgodbolt

Consider refactoring pivot using base of pagination control. At that point supporting overflowing of pivot items. #7254

micahgodbolt avatar Jan 17 '19 00:01 micahgodbolt

I believe the expected behavior would be for Pivots to scroll horizontally once they've exceeded their container's width. That's the pattern I've seen most frequently for this kind of behavior. @betrue-final-final , would be curious to hear if you have different thoughts.

Jahnp avatar Apr 03 '19 15:04 Jahnp

Same here, there isn't even a trigger we could handle the overflow ourselves. A good solution would be either to scroll the tabs horizontally, or to automatically collapse the over-flowed items into a "..." more drop down menu, when the page is resized and there is not enough room to render fully.

Anyone has a solution for this?

shaipetel avatar Apr 29 '19 18:04 shaipetel

For now, I'm doing it manually but adding a style to the pivot element:

<Pivot styles={{ root: { display: 'flex', flexWrap: 'wrap' } }}>

Works, but doesn't look great...

Just putting it out there in case anyone needs it.

shaipetel avatar Apr 29 '19 18:04 shaipetel

Another way i found was to give them a specific width, and make the text in the tab trncated with ...

using (for example with 4 tabs): <Pivot styles={{ linkIsSelected: { width: '25%' }, link: { width: '25%' }, text: { overflow: 'hidden', textOverflow: 'ellipsis', width: '100%' } }}>

and override the PivotItem render item link:

  return (<div style={{ width: '100%' }}>
    {defaultRenderer!(link)}
  </div>);
}}```

shaipetel avatar Apr 29 '19 19:04 shaipetel

Just as a design note: Pivots should never stack like that. It might 'solve' the overflow issue but it creates other problems and isn't an approved design. We should solve this holistically and thoughtfully within the component before we have multiple teams and products doing various different things here. I think ideally, all the places we have Pivots (UWP, Web, etc) align.

brandonthomas avatar May 20 '19 18:05 brandonthomas

Agreed. It's also worth mentioning that a fixed width will not work for a couple of reasons:

  • The current pivot indicator should be the width of the string
  • Will have inconsistent spacing between pivot items with long and short string lengths
  • Localization will be problematic

joetheday avatar May 20 '19 20:05 joetheday

Of course, a proper solution is much needed here, in the form of an overflow menu (...), or any other clever solution you come up with.

Since in my design I do not know the number or names of tabs I cannot hard code something like that with reasonable effort, I’m ok with my patches for now.

shaipetel avatar May 21 '19 01:05 shaipetel

I need Pivot to be rendered as vertical tabs with more than 9 tabs. Any suggestions ?

pratikgupta2 avatar May 22 '19 03:05 pratikgupta2

Yes @shaipetel is correct. We should leverage the common Fabric pattern of the overflow. Here’s the states: image

and examples: image

Pretty simple. If a pivot in the overflow is selected, then the selection visual should be used.

betrue-final-final avatar Jul 17 '19 17:07 betrue-final-final

Hey @micahgodbolt can we kick this up again?

betrue-final-final avatar Jul 17 '19 17:07 betrue-final-final

Yeah, this is certainly doable. Treat the top of the pivots like a command bar. It might require a decent bit of refactoring, but it's a good direction forward.

micahgodbolt avatar Jul 17 '19 18:07 micahgodbolt

Just wondering whether there is any plan to implement this in the roadmap? We are looking for the same kind of functionality.

mitch726 avatar Oct 18 '19 18:10 mitch726

Yah we should get on this sooner than later. We need it for WCAG 2.1 compliance.

brandonthomas avatar Oct 18 '19 21:10 brandonthomas

adding resizeGroup to this control would make it reasonably easy to achieve this, but it would also cause some issues for any pivot rendered in a flexible container

i.e. if the pivot parent only grows to be as big as the pivot, the resizable pivot will think it ran out of space and not try to grow.

For this reason, it's important that we make this change as an opt in prop for now.

micahgodbolt avatar Oct 18 '19 21:10 micahgodbolt

I'm ok with opt. Could we expose a prop of type ComponentType that renders as the wrapper? This way if someone wants some other component logic or behavior it's possible?

brandonthomas avatar Oct 18 '19 21:10 brandonthomas

we can expose the resizeGroup props and allow people to change the logic of the resizing for sure. We already do that on command bar. If you want to remove icons first, then see if it fits, you can do that before pushing items into the overflow.

micahgodbolt avatar Oct 18 '19 21:10 micahgodbolt

we can expose the resizeGroup props and allow people to change the logic of the resizing for sure. We already do that on command bar. If you want to remove icons first, then see if it fits, you can do that before pushing items into the overflow.

I have used the logic you have in command bar already and that works great so I would be happy to follow the same pattern here.

mitch726 avatar Oct 18 '19 22:10 mitch726

@micahgodbolt is there an ETA for this ?

sayali26 avatar Dec 17 '19 23:12 sayali26