Skip to content

[Feature]: react-positioning AutoSize improvements #28623

Description

@YuanboXue-Amber

Library

React Components / v9 (@fluentui/react-components)

Describe the feature that you would like added

Improve autoSize middleware:

1. Handle double scrollbar

Currently when autoSize is specified, it adds maxHeight/maxWidth style and overflowX/overflowY. But if the floating element has its own scrollable content, there can be double scrollbar:
https://codesandbox.io/s/blue-framework-mstvsn?file=/example.tsx
Screenshot 2023-07-24 at 15 15 58

1.a When the content of the floating element is expected, for example Menu:

We can remove the double scrollbar by shrinking the scrollable part.

1.b When the content of the floating element is unknown, for example Popover:

We need to way to let user override the inline style added by autoSize. Currently the only way to override these styles is by adding important!. For example if the user would like to make PopoverSurface not scrollable:

const useStyles = makeStyles({
  floating: {
    overflowY: "hidden !important" // to override the inline `overflowY:auto` style added by autoSize
  }
});

export const Default = () => {
  const styles = useStyles();
  return (
    <Popover positioning={{ autoSize: true }}>
      <PopoverTrigger disableButtonEnhancement>
        <Button>Toggle popover</Button>
      </PopoverTrigger>

      <PopoverSurface className={styles.floating}>
        <SomeHeader />
        <SomeScrollableContent />
        <SomeFooter />
      </PopoverSurface>
    </Popover>
  );
}

2. Consolidate 'height'/'height-always' option (and 'width'/'width-always', true/'always')

AutoSize now have so many options, for example when autoSize=true, styles are applied only when overflow happens, and when autoSize='always', styles are applied all the time regardless of overflow.

We can consolidate the xxx/xxx-always option if we always apply max-height/max-width (case A happy), but clear them to restore floating element to its original size when updatePosition is called (case B also happy).

Have you discussed this feature with our team

teams-prg

Additional context

No response

Validations

  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions