Skip to content

Commit 47ce558

Browse files
committed
Fix responsive option labels in dropdown
1 parent 9166dad commit 47ce558

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

components/dash-core-components/src/components/Dropdown.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export default function Dropdown({
3030
multi = false,
3131
searchable = true,
3232
localizations = defaultLocalizations,
33-
// eslint-disable-next-line no-magic-numbers
34-
optionHeight = 36,
33+
optionHeight = 'auto',
3534
// eslint-disable-next-line no-magic-numbers
3635
maxHeight = 200,
3736
closeOnSelect = !multi,

components/dash-core-components/src/components/css/dropdown.css

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@
6161

6262
.dash-dropdown-content {
6363
background: var(--Dash-Fill-Inverse-Strong);
64-
min-width: fit-content;
65-
width: var(--radix-popover-trigger-width);
64+
width: fit-content;
65+
min-width: var(--radix-popover-trigger-width);
66+
max-width: 100vw;
6667
overflow-y: auto;
6768
z-index: 50;
6869
box-shadow: 0px 10px 38px -10px rgba(22, 23, 24, 0.35),
@@ -190,7 +191,7 @@
190191
}
191192

192193
.dash-dropdown-option {
193-
padding: var(--Dash-Spacing) calc(var(--Dash-Spacing) * 3);
194+
padding: calc(var(--Dash-Spacing) * 2) calc(var(--Dash-Spacing) * 3);
194195
background: var(--Dash-Fill-Inverse-strong);
195196
box-shadow: 0 -1px 0 0 var(--Dash-Fill-Disabled) inset;
196197
color: var(--Dash-Text-Strong);
@@ -212,10 +213,6 @@
212213
cursor: not-allowed;
213214
}
214215

215-
.dash-dropdown-option-text {
216-
white-space: pre;
217-
}
218-
219216
.dash-dropdown-option-checkbox {
220217
display: inline-block;
221218
margin: 0 calc(var(--Dash-Spacing) * 2) 0 0;

components/dash-core-components/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ export interface DropdownProps {
443443
/**
444444
* height of each option. Can be increased when label lengths would wrap around
445445
*/
446-
optionHeight?: number;
446+
optionHeight?: 'auto' | number;
447447

448448
/**
449449
* height of the options dropdown.

0 commit comments

Comments
 (0)