diff --git a/patches/helium/ui/side-panel.patch b/patches/helium/ui/side-panel.patch index d830f3c1..0244b3ff 100644 --- a/patches/helium/ui/side-panel.patch +++ b/patches/helium/ui/side-panel.patch @@ -64,3 +64,68 @@ } } +// Reduce minimum acceptable side panel content width without changing the default size. +--- a/chrome/browser/ui/views/side_panel/side_panel.cc ++++ b/chrome/browser/ui/views/side_panel/side_panel.cc +@@ -419,8 +419,7 @@ void SidePanel::UpdateWidthOnEntryChange + // 1. Use the user's manually resized width + // 2. Use the side panels default width + // NOTE: If not specified, the side panel will default to +- // SidePanelEntry::kSidePanelDefaultContentWidth which evaluates to the same +- // value as GetMinimumSize(). ++ // SidePanelEntry::kSidePanelDefaultContentWidth + if (std::optional width_from_pref = dict.FindInt(panel_id)) { + SetPanelWidth(width_from_pref.value()); + } else { +@@ -444,6 +443,13 @@ bool SidePanel::IsRightAligned() const { + gfx::Size SidePanel::GetMinimumSize() const { + const int min_height = 0; + return gfx::Size( ++ SidePanelEntry::kSidePanelMinimumContentWidth + GetBorderInsets().width(), ++ min_height); ++} ++ ++gfx::Size SidePanel::GetDefaultSize() const { ++ const int min_height = 0; ++ return gfx::Size( + SidePanelEntry::kSidePanelDefaultContentWidth + GetBorderInsets().width(), + min_height); + } +@@ -614,6 +620,13 @@ void SidePanel::OnResize(int resize_amou + proposed_width = minimum_width; + } + ++ // Snap to default_width if the proposed_width is close enough. ++ const int default_width = GetDefaultSize().width(); ++ const int snap_diff = 20; ++ if (abs(proposed_width - default_width) < snap_diff) { ++ proposed_width = default_width; ++ } ++ + if (width() != proposed_width) { + if (SidePanelUI* side_panel_ui = + browser_view_->browser()->GetFeatures().side_panel_ui()) { +--- a/chrome/browser/ui/views/side_panel/side_panel_entry.h ++++ b/chrome/browser/ui/views/side_panel/side_panel_entry.h +@@ -38,8 +38,10 @@ class SidePanelEntry final : public ui:: + kToolbar, + }; + +- // The default and minimum acceptable side panel content width. ++ // The default side panel content width. + static constexpr int kSidePanelDefaultContentWidth = 360; ++ // The minimum acceptable side panel content width ++ static constexpr int kSidePanelMinimumContentWidth = 260; + using CreateContentCallback = + base::RepeatingCallback( + SidePanelEntryScope&)>; +--- a/chrome/browser/ui/views/side_panel/side_panel.h ++++ b/chrome/browser/ui/views/side_panel/side_panel.h +@@ -51,6 +51,7 @@ class SidePanel : public views::Accessib + HorizontalAlignment GetHorizontalAlignment() const; + bool IsRightAligned() const; + gfx::Size GetMinimumSize() const override; ++ gfx::Size GetDefaultSize() const; + bool IsClosing(); + void DisableAnimationsForTesting() { animations_disabled_ = true; } + void SetKeyboardResized(bool keyboard_resized) {