Skip to content

Commit 0271d08

Browse files
committed
Use MenuStyle instead of MenuWidth and MenuAnchor
1 parent 98d8c24 commit 0271d08

File tree

3 files changed

+7
-34
lines changed

3 files changed

+7
-34
lines changed

src/LoreSoft.Blazor.Controls/Typeahead/Typeahead.razor.cs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,11 @@ public partial class Typeahead<TItem, TValue> : StandardComponent
180180
public FieldIdentifier FieldIdentifier { get; set; }
181181

182182
/// <summary>
183-
/// Gets or sets the explicit width of the dropdown menu. When not set, the menu matches the control width.
184-
/// Accepts any valid CSS width value (e.g., <c>"300px"</c>, <c>"20rem"</c>).
183+
/// Gets or sets the explicit style of the dropdown menu. When not set, the menu matches the control width.
184+
/// Accepts any valid CSS style value (e.g., <c>"width: 300px;"</c>, <c>"width: 20rem;"</c>).
185185
/// </summary>
186186
[Parameter]
187-
public string? MenuWidth { get; set; }
188-
189-
/// <summary>
190-
/// Gets or sets the anchor edge from which the dropdown menu is aligned.
191-
/// Defaults to <see cref="MenuAnchor.Left"/>.
192-
/// </summary>
193-
[Parameter]
194-
public MenuAnchor MenuAnchor { get; set; } = MenuAnchor.Left;
187+
public string? MenuStyle { get; set; }
195188

196189
/// <summary>
197190
/// Gets a value indicating whether the control is currently loading search results.
@@ -235,7 +228,7 @@ public partial class Typeahead<TItem, TValue> : StandardComponent
235228
protected List<TItem> CurrentItems { get; set; } = [];
236229

237230
/// <summary>
238-
/// Gets the computed inline style applied to the dropdown menu, derived from <see cref="MenuWidth"/> and <see cref="MenuAnchor"/>.
231+
/// Gets the computed inline style applied to the dropdown menu, derived from <see cref="MenuStyle"/>.
239232
/// </summary>
240233
protected string? CurrentMenuStyle { get; private set; }
241234

@@ -260,9 +253,7 @@ protected override void OnParametersSet()
260253
CurrentMenuStyle = StyleBuilder.Pool.Use(builder =>
261254
{
262255
return builder
263-
.AddStyle("width", MenuWidth, (v) => v.HasValue())
264-
.AddStyle("left", "0", MenuAnchor is MenuAnchor.Left)
265-
.AddStyle("right", "0", MenuAnchor is MenuAnchor.Right)
256+
.AddStyle(MenuStyle)
266257
.ToString();
267258
});
268259
}
@@ -600,14 +591,3 @@ private void MoveSelection(int count)
600591
throw new InvalidOperationException($"Typeahead component requires a {nameof(ConvertMethod)} parameter.");
601592
}
602593
}
603-
604-
/// <summary>
605-
/// Specifies the edge of the typeahead control to which the dropdown menu is anchored.
606-
/// </summary>
607-
public enum MenuAnchor
608-
{
609-
/// <summary>The menu aligns to the left edge of the control.</summary>
610-
Left,
611-
/// <summary>The menu aligns to the right edge of the control.</summary>
612-
Right
613-
}

src/LoreSoft.Blazor.Controls/wwwroot/css/typeahead.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
font-size: inherit;
234234
width: 100%;
235235
user-select: none;
236-
-webkit-tap-highlight-color: #000 0;
236+
-webkit-tap-highlight-color: #000;
237237
box-sizing: border-box;
238238
padding: 8px 12px;
239239
}

test/LoreSoft.Blazor.Controls.Tests/Snapshots/PublicApiTest.PublicApiHasNotChanged.verified.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,6 @@ namespace LoreSoft.Blazor.Controls
10271027
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder) { }
10281028
protected override System.Threading.Tasks.Task OnAfterRenderAsync(bool firstRender) { }
10291029
}
1030-
public enum MenuAnchor
1031-
{
1032-
Left = 0,
1033-
Right = 1,
1034-
}
10351030
public class ModalClose : System.IEquatable<LoreSoft.Blazor.Controls.ModalClose>
10361031
{
10371032
public ModalClose(LoreSoft.Blazor.Controls.ModalReference Modal) { }
@@ -1632,9 +1627,7 @@ namespace LoreSoft.Blazor.Controls
16321627
[Microsoft.AspNetCore.Components.Parameter]
16331628
public System.Func<TValue?, System.Threading.Tasks.Task<TItem?>>? LookupMethod { get; set; }
16341629
[Microsoft.AspNetCore.Components.Parameter]
1635-
public LoreSoft.Blazor.Controls.MenuAnchor MenuAnchor { get; set; }
1636-
[Microsoft.AspNetCore.Components.Parameter]
1637-
public string? MenuWidth { get; set; }
1630+
public string? MenuStyle { get; set; }
16381631
[Microsoft.AspNetCore.Components.Parameter]
16391632
public int MinimumLength { get; set; }
16401633
[Microsoft.AspNetCore.Components.Parameter]

0 commit comments

Comments
 (0)