Skip to content

Commit

Permalink
Test select changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yueying Lu committed Feb 12, 2025
1 parent 7c8f26d commit cf396d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pages/select/select.test.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ export default function SelectPage() {
<ScreenshotArea>
<Box padding="l">
<Box padding="s">
<div style={{ height: '700px' }}></div>
<Box variant="h1">Overflow test</Box>
<Box variant="p">Dropdown should not be rendered beyond the container with overflow hidden</Box>
<div id="smallest_container" style={{ overflow: 'hidden', blockSize: '500px', padding: 0 }}>
<div
id="smallest_container"
style={{ overflow: 'hidden', blockSize: '500px', padding: 0, backgroundColor: 'red' }}
>
<div style={{ overflow: 'hidden', blockSize: '900px' }}>
<Select
id="select_overflow"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/components/dropdown/dropdown-fit-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export const getDropdownPosition = ({
availableSpace.blockEnd < dropdownElement.offsetHeight && availableSpace.blockStart > availableSpace.blockEnd;
const availableHeight = dropBlockStart ? availableSpace.blockStart : availableSpace.blockEnd;
// Try and crop the bottom item when all options can't be displayed, affordance for "there's more"
const croppedHeight = stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16;
const croppedHeight = Math.max(stretchHeight ? availableHeight : Math.floor(availableHeight / 31) * 31 + 16, 15);

return {
dropBlockStart,
Expand Down
4 changes: 3 additions & 1 deletion src/select/parts/plain-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const PlainList = (
() => (index: number) => {
const item = menuRef.current?.querySelector<HTMLElement>(`[data-mouse-target="${index}"]`);
if (highlightType.moveFocus && item) {
scrollElementIntoView(item);
if (menuRef.current?.clientHeight !== undefined && menuRef.current?.clientHeight > 15) {
scrollElementIntoView(item);
}
}
},
[highlightType, menuRef]
Expand Down

0 comments on commit cf396d3

Please sign in to comment.