Skip to content

Commit a1de590

Browse files
committed
Tweak Autocomplete dropdowns styling
Change-type: patch
1 parent 27f3bdf commit a1de590

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/components/VirtualizedAutocomplete/index.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import throttle from 'lodash/throttle';
1010
import * as React from 'react';
1111
import { VList } from 'virtua';
1212

13-
const MUI_LIST_VERTICAL_PADDING = 8;
14-
1513
interface ItemDataElement {
1614
props: React.HTMLAttributes<HTMLElement>;
1715
option: React.ReactNode;
@@ -28,20 +26,18 @@ const ListboxComponent = ({
2826
}) => {
2927
const itemData = (children as ItemDataElement[]).slice();
3028
const { itemCount, loadNextPage } = props.pagination;
31-
const [optionHeightsTotal, setOptionHeightsTotal] = React.useState(
32-
MUI_LIST_VERTICAL_PADDING * 2,
33-
);
29+
const [optionHeightsTotal, setOptionHeightsTotal] = React.useState(0);
3430

3531
React.useEffect(() => {
3632
if (!isNextPageLoading) {
37-
setOptionHeightsTotal(MUI_LIST_VERTICAL_PADDING * 2);
33+
setOptionHeightsTotal(0);
3834
}
3935
}, [isNextPageLoading]);
4036

4137
React.useEffect(() => {
4238
if (optionHeightsTotal < document.documentElement.clientHeight * 0.4) {
4339
const options = document.getElementsByClassName('MuiAutocomplete-option');
44-
let total = MUI_LIST_VERTICAL_PADDING * 2;
40+
let total = 0;
4541
for (const option of options) {
4642
total += option.clientHeight;
4743
}
@@ -70,8 +66,6 @@ const ListboxComponent = ({
7066
<VList
7167
style={{
7268
flex: 1,
73-
paddingTop: MUI_LIST_VERTICAL_PADDING,
74-
paddingBottom: MUI_LIST_VERTICAL_PADDING,
7569
}}
7670
onRangeChange={(_, lastItemIndex) => {
7771
if (

src/theme.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,9 @@ export const theme = createTheme({
896896
MuiPopper: {
897897
styleOverrides: {
898898
root: ({ theme }) => ({
899+
'.MuiAutocomplete-listbox': {
900+
padding: 0,
901+
},
899902
'.MuiAutocomplete-option': {
900903
paddingTop: theme.spacing(3),
901904
paddingBottom: theme.spacing(3),

0 commit comments

Comments
 (0)