Skip to content

Commit a7824c7

Browse files
authored
fix: v8 Picker suggestions handle scroll overflow at small screen sizes (#34312)
1 parent 94aeaad commit a7824c7

File tree

7 files changed

+33
-5
lines changed

7 files changed

+33
-5
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix: Picker suggestions handle scroll overflow at small screen sizes",
4+
"packageName": "@fluentui/react",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react/etc/react.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ export class BasePicker<T extends {}, P extends IBasePickerProps<T>> extends Rea
772772
// (undocumented)
773773
protected renderLabel(inputId: string, styles: IStyleFunctionOrObject<ILabelStyleProps, ILabelStyles> | undefined): JSX.Element | null;
774774
// (undocumented)
775-
protected renderSuggestions(): JSX.Element | null;
775+
protected renderSuggestions(styles: IStyleFunctionOrObject<ICalloutContentStyleProps, ICalloutContentStyles> | undefined): JSX.Element | null;
776776
// (undocumented)
777777
protected resetFocus(index?: number): void;
778778
// (undocumented)

packages/react/src/components/pickers/BasePicker.styles.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ export function getStyles(props: IBasePickerStyleProps): IBasePickerStyles {
164164
screenReaderText: hiddenContentStyle,
165165
subComponentStyles: {
166166
label: {},
167+
callout: {
168+
// Picker suggestions already manage overflow and scrolling items into view
169+
// for this to work at all screen sizes, we need Callout to not also have overflow
170+
calloutMain: {
171+
overflow: 'unset',
172+
maxHeight: '100%',
173+
},
174+
},
167175
},
168176
};
169177
}

packages/react/src/components/pickers/BasePicker.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import type { IPickerItemProps } from './PickerItem.types';
3434
import { WindowContext } from '@fluentui/react-window-provider';
3535
import { getDocumentEx } from '../../utilities/dom';
3636
import type { ILabelStyleProps, ILabelStyles } from '../../Label';
37+
import type { ICalloutContentStyleProps, ICalloutContentStyles } from '../../Callout';
3738

3839
const legacyStyles: any = stylesImport;
3940

@@ -372,7 +373,7 @@ export class BasePicker<T extends {}, P extends IBasePickerProps<T>>
372373
</div>
373374
</SelectionZone>
374375
{this.renderError(classNames.error)}
375-
{this.renderSuggestions()}
376+
{this.renderSuggestions(classNames.subComponentStyles?.callout)}
376377
</div>
377378
);
378379
}
@@ -421,7 +422,9 @@ export class BasePicker<T extends {}, P extends IBasePickerProps<T>>
421422
);
422423
}
423424

424-
protected renderSuggestions(): JSX.Element | null {
425+
protected renderSuggestions(
426+
styles: IStyleFunctionOrObject<ICalloutContentStyleProps, ICalloutContentStyles> | undefined,
427+
): JSX.Element | null {
425428
const StyledTypedSuggestions: React.FunctionComponent<ISuggestionsProps<T>> = this._styledSuggestions;
426429

427430
return this.state.suggestionsVisible && this.input ? (
@@ -434,6 +437,7 @@ export class BasePicker<T extends {}, P extends IBasePickerProps<T>>
434437
directionalHintForRTL={DirectionalHint.bottomRightEdge}
435438
// eslint-disable-next-line react/jsx-no-bind
436439
preventDismissOnEvent={(ev: Event) => this._preventDismissOnScrollOrResize(ev)}
440+
styles={styles}
437441
{...this.props.pickerCalloutProps}
438442
>
439443
<StyledTypedSuggestions
@@ -1274,7 +1278,7 @@ export class BasePickerListBelow<T extends {}, P extends IBasePickerProps<T>> ex
12741278
/>
12751279
</div>
12761280
</div>
1277-
{this.renderSuggestions()}
1281+
{this.renderSuggestions(classNames.subComponentStyles?.callout)}
12781282
<SelectionZone selection={this.selection} selectionMode={SelectionMode.single}>
12791283
<div
12801284
id={this._ariaMap.selectedItems}

packages/react/src/components/pickers/BasePicker.types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Autofill } from '../../Autofill';
33
import type { IPickerItemProps } from './PickerItem.types';
44
import type { IReactProps, IRefObject, IStyleFunctionOrObject } from '../../Utilities';
55
import type { ISuggestionModel, ISuggestionsProps } from './Suggestions/Suggestions.types';
6-
import type { ICalloutProps } from '../../Callout';
6+
import type { ICalloutProps, ICalloutContentStyleProps, ICalloutContentStyles } from '../../Callout';
77
import type { ITheme, IStyle } from '../../Styling';
88
import type { ISuggestionItemProps } from '../pickers/Suggestions/SuggestionsItem.types';
99
import { IIconProps } from '../Icon/Icon.types';
@@ -367,6 +367,9 @@ export type IBasePickerStyleProps = Pick<IBasePickerProps<any>, 'theme' | 'class
367367
export interface IBasePickerSubComponentStyles {
368368
/** Styling for Label child component. */
369369
label: IStyleFunctionOrObject<ILabelStyleProps, ILabelStyles>;
370+
371+
/** Styling for Callout child component. */
372+
callout: IStyleFunctionOrObject<ICalloutContentStyleProps, ICalloutContentStyles>;
370373
}
371374

372375
/**

packages/react/src/components/pickers/Suggestions/Suggestions.styles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ export function getStyles(props: ISuggestionsStyleProps): ISuggestionsStyles {
8282
root: [
8383
classNames.root,
8484
{
85+
display: 'flex',
86+
flexDirection: 'column',
8587
minWidth: 260,
88+
maxHeight: '100%',
8689
},
8790
className,
8891
],

packages/react/src/components/pickers/Suggestions/__snapshots__/Suggestions.test.tsx.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,9 @@ exports[`Suggestions renders a list properly with CSS-in-JS styles 1`] = `
23722372
className=
23732373
ms-Suggestions
23742374
{
2375+
display: flex;
2376+
flex-direction: column;
2377+
max-height: 100%;
23752378
min-width: 260px;
23762379
}
23772380
role="listbox"

0 commit comments

Comments
 (0)