fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Render VirtualizedComboBox items under the dropdown selector with option for max height / items

Open WillFrasier opened this issue 6 years ago • 7 comments

Describe the feature that you would like added

Currently when the VirtualizedComboBox renders more than a certain number of items the actual list of items to select render to the side of the control. Many folks in my team have mention that this is a bug until I realized that this is the currently desired behavior.

What component or utility would this be added to

Option to render the items for a combo box directly under the combo box selector. Option to control how many items are rendered. I.e. right now it just takes up the whole screen. I would like to only render N items or have a max width of N pixels

Have you discussed this feature with our team, and if so, who

Nope

Links / Screenshots

https://codepen.io/willfrasier/pen/bGVZVKJ?editors=0010

image

The desired behaviour is something more like this:

  • Items rendered under select
  • item count capped at either number of items or height

image

WillFrasier avatar May 22 '20 22:05 WillFrasier

@WillFrasier Thanks for reaching out to us! As you said I believe this behaviour is intended by design so we will consider as a feature request and add it to the backlog for review. It might take a while to get to it as we're currently focused on larger work items like performance and coherence (see V8 issue pinned on repo). @joschect is this a behaviour that we might want to consider to implement as a new feature and if so, what should be the priority?

aneeshack4 avatar May 26 '20 15:05 aneeshack4

I think issue comes from the fact that callout grows beyond page size.

You can try to workaround this issue using some styles, just limit size of callout and options' container of VirtualizedComboBox, like for example so:

const comboBoxStyles: Partial<IComboBoxStyles> = { 
  root: { 
    maxWidth: '300px' 
  },
  callout: {
    maxHeight: '300px',
  },
  optionsContainerWrapper: {
    maxHeight: '300px',
  },
  optionsContainer: {
    maxHeight: '300px',
  },
};

shytikov avatar Jun 15 '20 20:06 shytikov

Thanks @shytikov . This didn't seem to have any effect. Can you please post a link to a live example?

image

WillFrasier avatar Jul 21 '20 18:07 WillFrasier

@WillFrasier, the correct property of the VirtualizedComboBox to set a max height and to prevent that repositioning is calloutProps (interface ICalloutProps).

<VirtualizedComboBox
    ...
    useComboBoxAsMenuWidth={true}
    calloutProps={{
        calloutMaxHeight: 300,
    }}
 />

You can check it in an updated codepen.

fheinicke avatar Jul 31 '20 12:07 fheinicke

Setting calloutMaxHeight is a nice workaround (thank you! 🙏 ), but I'd also appreciate a reposition boolean or something similar that would then dynamically set the height of the Callout based on position and available viewport space.

zulaica avatar Aug 26 '20 21:08 zulaica

Never mind! directionalHintFixed is the prop I was looking for.

calloutProps={{
  directionalHintFixed: true,
}}

zulaica avatar Aug 26 '20 22:08 zulaica

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

msft-fluent-ui-bot avatar Apr 26 '21 11:04 msft-fluent-ui-bot