Skip to content

Commit a69c610

Browse files
authored
Code Quality: Fixed a crash that often happens when switching between Omnibar modes (#17226)
1 parent c7f3829 commit a69c610

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Files.App.Controls/Omnibar/Omnibar.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ protected void ChangeMode(OmnibarMode? oldMode, OmnibarMode newMode)
132132
if (oldMode is not null)
133133
VisualStateManager.GoToState(oldMode, "Unfocused", true);
134134

135-
// Reset
136-
foreach (var column in _modesHostGrid.ColumnDefinitions)
137-
column.Width = GridLength.Auto;
135+
DispatcherQueue.TryEnqueue(() =>
136+
{
137+
// Reset
138+
foreach (var column in _modesHostGrid.ColumnDefinitions)
139+
column.Width = GridLength.Auto;
138140

139-
// Expand the given mode
140-
_modesHostGrid.ColumnDefinitions[index].Width = new(1, GridUnitType.Star);
141+
// Expand the given mode
142+
_modesHostGrid.ColumnDefinitions[index].Width = new(1, GridUnitType.Star);
143+
});
141144

142145
var itemCount = Modes.Count;
143146
var itemIndex = Modes.IndexOf(newMode);

0 commit comments

Comments
 (0)