The “maxHeight” prop should expand the height of the dropdown, which it does. However, it does not expand the height of the background.
If you have a look at the Dash example: Dropdown | Dash for Python Documentation | Plotly you can see that normally “Rome” would not fit on the dropdown. With maxHeight=300 “Rome” now fits in the dropdown, but but the white background height has not been increased (same issue in dark mode).
I see the issue in the docs, but running that minimal example on it’s own, everything looks fine. It might be just be an issue with some custom CSS that’s used in the docs.
I have this issue currently while running Dash 2.17.0. If I run the minimal example from the docs, everything is fine, though in my actual dashboard, the background is not correctly extended. I have looked at my custom CSS styling but I can’t really see what is interfering here. Any direction what is overriding the dropdown styling? I am using the external style sheet dbc.themes.BOOTSTRAP.
The custom stylings that I have are either updating colors or very specific parts of components (none of which I can really relate to the dropdown).
Any idea what class to look for, or is the overwriting coming from the BOOTSTRAP styling?
It took me a while to find some time and then another while to actually isolate the issue. And I found it. The issue is with dash_table. Below is a small example to demonstrate the bug. I tested this in a fresh virtual environment where I just installed the latest version of Dash and its dependencies
pip install dash
The bug appears when a dash_table.DataTable() component exists in the layout. It doesn’t need to contain any data. When I run the example below, I get
As you see, the dropdown background does not get extended. When I comment the dash_table.DataTable(), line, the background is properly extended
I added another line where the DataTable is part of an html.Div which is hidden, to show that the bug also appears in that case.
My conclusion here is that initializing a DataTable somehow loads extra styles that interfere with the dropdown. Note that there is no custom styling defined, the example works as-is.
I guess I should create a github issue on this.
Edit: There are actually already issues posted on this issue:
# app.py
from dash import dcc, Dash, html, dash_table
app = Dash(__name__)
app.layout = html.Div(
children=[
# html.Div([dash_table.DataTable()], style={"display": "none"}),
dash_table.DataTable(),
dcc.Dropdown(
options=[
{"label": i, "value": i}
for i in [
"New York City",
"Montreal",
"Paris",
"London",
"Amsterdam",
"Berlin",
"Rome",
]
],
value="New York City",
optionHeight=50,
maxHeight=500,
),
],
)
I made a suggestion for how that could be solved, but I don’t know how to implement that.
Edit:
Trying out your solution, I found that this also works. This combination is located higher in the css styling list, so you can circumvent the use of the !important keyword.
Edit 2:
For those using this workaround: you still need to set the maxHeight property in dcc.Dropdown besides the extra css style to enable the extension of the dropdown menu. Secondly, don’t set a value in the custom css style, set it to none. Otherwise, you can get interference between what is set in the custom css style and what is set by maxHeight. By setting the custom css to none, the behavior is fully controlled by the maxHeight property, just as intended.