Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions leafmap/maplibregl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10630,7 +10630,10 @@ def build_layer_controls(self) -> None:
checkbox = widgets.Checkbox(
value=visible, description=name, style=style, indent=False
)
checkbox.layout.flex = "1 1 auto"
# Use a zero flex basis so the checkbox only takes the space left
# over by the slider and buttons. With an "auto" basis, its default
# 300px width squeezes the opacity slider down to its minimum.
checkbox.layout.flex = "1 1 0"
checkbox.layout.min_width = "0"
checkbox.layout.overflow = "hidden"

Expand All @@ -10642,9 +10645,9 @@ def build_layer_controls(self) -> None:
readout=False,
tooltip="Change layer opacity",
layout=widgets.Layout(
flex="0 1 90px",
flex="0 0 auto",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low confidence: the slider is now rigid (flex: 0 0 auto, min_width: 90px), and the checkbox has min_width=0 and overflow=hidden with a zero basis. In a narrow sidebar, or with long layer names, the checkbox label shrinks to nothing and gets clipped, and the slider never gives up space. Before this change the slider could shrink to 40px. Consider keeping a small shrink allowance, for example flex="0 1 90px" with min_width="60px". Alternatively, give the checkbox a modest min_width so labels stay readable.

width="90px",
min_width="40px",
min_width="90px",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low-confidence concern: the slider is now rigid (flex="0 0 auto", min_width="120px"). The checkbox can shrink to 0 (flex 1 1 0, min_width=0), but the slider can't. In a panel narrower than roughly 120px plus the buttons and padding, the row would overflow and could push the buttons out. The test only covered a 340px panel. A shrinkable slider would keep the old safety valve, for example flex="0 1 120px" with a smaller min_width such as 60px. The checkbox's zero basis already fixes the original squeeze, so this would keep the fix and still let narrow panels degrade gracefully.

Suggested change
min_width="90px",
flex="0 1 120px",
width="120px",
min_width="60px",

padding=padding,
),
)
Expand Down Expand Up @@ -11019,7 +11022,8 @@ def __init__(
layout=widgets.Layout(width="auto"),
)

self.output_widget = widgets.Output()
# No margin so the empty output area adds no space below the buttons.
self.output_widget = widgets.Output(layout=widgets.Layout(margin="0"))

# Button container
self.button_box = widgets.HBox([self.apply_btn, self.reset_btn, self.close_btn])
Expand All @@ -11029,8 +11033,10 @@ def __init__(
self.reset_btn.on_click(self._reset_style)
self.close_btn.on_click(self._close_widget)

# Layout
self.layout = widgets.Layout(width="300px", padding="10px")
# Layout. No padding: the sidebar panel already pads its content, and
# extra padding leaves a gap below the buttons and misaligns the
# content with the other panels.
self.layout = widgets.Layout(width="300px", padding="0")

# Combine all widgets
self.children = [*self.style_widgets, self.button_box, self.output_widget]
Expand Down
Loading