Skip to content

Commit 42dd426

Browse files
[Rename flyout] Fixed cropping issue on small screens (#77466)
# Problem Rename flyout is being cropped on small screens. The issue being that: 1. The flyout is larger than the document's view port 2. The flyout's left position is negative (which makes it disappear to the left). 3. Text within the flyout doesn't wrap. ![image](https://github.com/user-attachments/assets/c33a2b34-a942-409b-b87b-7016445a1df2) # Solution Basically, address all of the above: 1. Limit the size of the flyout to the width of the document's view port. 2. Ensure the flyout's position is always positive. 3. Wrap text blocks. ![image](https://github.com/user-attachments/assets/d09f4013-f440-4c6d-8f2e-5d8064bc48d1)
2 parents 554a1dd + 0e72446 commit 42dd426

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/EditorFeatures/Core.Wpf/InlineRename/UI/Adornment/RenameFlyout.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
xmlns:vsui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0"
1313
mc:Ignorable="d"
1414
d:DesignHeight="450" d:DesignWidth="800"
15-
MinWidth="200"
1615
KeyDown="Adornment_KeyDown"
1716
MouseDown="Adornment_ConsumeMouseEvent"
1817
MouseUp="Adornment_ConsumeMouseEvent"
@@ -97,13 +96,14 @@
9796
</Grid.ColumnDefinitions>
9897

9998
<imaging:CrispImage Grid.Column="0" Moniker="{Binding StatusImageMoniker}" />
100-
<TextBlock Grid.Column="1" Text="{Binding StatusText}" />
99+
<TextBlock Grid.Column="1" Text="{Binding StatusText}" TextWrapping="Wrap" />
101100
</Grid>
102101

103102
<TextBlock
104103
Text="{Binding SearchText}"
105104
Visibility="{Binding ShowSearchText, Converter={StaticResource BooleanToVisibilityConverter}}"
106105
FontWeight="Light"
106+
TextWrapping="Wrap"
107107
VerticalAlignment="Center"
108108
Margin="0,0,0,5" />
109109

@@ -125,6 +125,7 @@
125125
Text="{Binding ElementName=control, Path=SubmitText}"
126126
Margin="5, 5, 0, 0"
127127
FontStyle="Italic"
128+
TextWrapping="Wrap"
128129
/>
129130
</StackPanel>
130131
</Border>

src/EditorFeatures/Core.Wpf/InlineRename/UI/Adornment/RenameFlyout.xaml.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
2323
/// </summary>
2424
internal partial class RenameFlyout : InlineRenameAdornment
2525
{
26+
private const int DefaultMinWidth = 200;
27+
2628
private readonly RenameFlyoutViewModel _viewModel;
2729
private readonly IEditorFormatMap _editorFormatMap;
2830
private readonly IWpfTextView _textView;
@@ -147,8 +149,11 @@ private void PositionAdornment()
147149
? _textView.ViewportRight - width
148150
: desiredLeft;
149151

150-
Canvas.SetTop(this, top);
151-
Canvas.SetLeft(this, left);
152+
MaxWidth = _textView.ViewportRight;
153+
MinWidth = Math.Min(DefaultMinWidth, _textView.ViewportWidth);
154+
155+
Canvas.SetTop(this, Math.Max(0, top));
156+
Canvas.SetLeft(this, Math.Max(0, left));
152157
}
153158

154159
public override void Dispose()

0 commit comments

Comments
 (0)