Skip to content

Commit 5cc4272

Browse files
committed
Make smaller if fewer (or none) hidden
1 parent f87dc3a commit 5cc4272

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/reactComponents/AddTabDialog.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ interface AddTabDialogProps {
4848

4949
/** Height of the scrollable lists in pixels. */
5050
const LIST_HEIGHT = 200;
51+
const ITEM_HEIGHT = 45;
52+
const EMPTY_HEIGHT = 60;
5153

5254
/**
5355
* Dialog component for adding new tabs to the workspace.
@@ -131,6 +133,10 @@ export default function AddTabDialog(props: AddTabDialogProps) {
131133
}
132134
};
133135

136+
const getListHeight = (): number => {
137+
return Math.max(EMPTY_HEIGHT, Math.min(LIST_HEIGHT, availableItems.length * ITEM_HEIGHT));
138+
}
139+
134140
return (
135141
<Antd.Modal
136142
title={t('addTabDialog.title')}
@@ -159,7 +165,7 @@ export default function AddTabDialog(props: AddTabDialogProps) {
159165
<Antd.List
160166
size="small"
161167
bordered
162-
style={{height: LIST_HEIGHT, overflow: 'auto', marginBottom: 16}}
168+
style={{height: getListHeight(), overflow: 'auto', marginBottom: 16}}
163169
dataSource={availableItems}
164170
renderItem={(item) => (
165171
<Antd.List.Item

0 commit comments

Comments
 (0)