Skip to content

Commit bbe8115

Browse files
committed
add PreserveCalloutWidth option to callout infrastructure #11505
1 parent f568119 commit bbe8115

File tree

13 files changed

+162
-119
lines changed

13 files changed

+162
-119
lines changed

src/BlazorUI/Bit.BlazorUI/Components/Buttons/MenuButton/BitMenuButton.razor.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -578,20 +578,23 @@ private async Task ToggleCallout()
578578
{
579579
if (IsEnabled is false || IsDisposed) return;
580580

581-
await _js.BitCalloutToggleCallout(_dotnetObj,
582-
_Id,
583-
null,
584-
_calloutId,
585-
null,
586-
IsOpen,
587-
BitResponsiveMode.None,
588-
BitDropDirection.TopAndBottom,
589-
Dir is BitDir.Rtl,
590-
"",
591-
0,
592-
"",
593-
"",
594-
true);
581+
await _js.BitCalloutToggleCallout(
582+
dotnetObj: _dotnetObj,
583+
componentId: _Id,
584+
component: null,
585+
calloutId: _calloutId,
586+
callout: null,
587+
isCalloutOpen: IsOpen,
588+
responsiveMode: BitResponsiveMode.None,
589+
dropDirection: BitDropDirection.TopAndBottom,
590+
isRtl: Dir is BitDir.Rtl,
591+
scrollContainerId: "",
592+
scrollOffset: 0,
593+
headerId: "",
594+
footerId: "",
595+
setCalloutWidth: true,
596+
preserveCalloutWidth: false,
597+
maxWindowWidth: 0);
595598
}
596599

597600
private void OnSetIsOpen()

src/BlazorUI/Bit.BlazorUI/Components/Inputs/CircularTimePicker/BitCircularTimePicker.razor.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -536,20 +536,23 @@ private async Task ToggleCallout()
536536
if (Standalone) return;
537537
if (IsEnabled is false || IsDisposed) return;
538538

539-
await _js.BitCalloutToggleCallout(_dotnetObj,
540-
_circularTimePickerId,
541-
null,
542-
_calloutId,
543-
null,
544-
IsOpen,
545-
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
546-
BitDropDirection.TopAndBottom,
547-
Dir is BitDir.Rtl,
548-
"",
549-
0,
550-
"",
551-
"",
552-
false);
539+
await _js.BitCalloutToggleCallout(
540+
dotnetObj: _dotnetObj,
541+
componentId: _circularTimePickerId,
542+
component: null,
543+
calloutId: _calloutId,
544+
callout: null,
545+
isCalloutOpen: IsOpen,
546+
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
547+
dropDirection: BitDropDirection.TopAndBottom,
548+
isRtl: Dir is BitDir.Rtl,
549+
scrollContainerId: "",
550+
scrollOffset: 0,
551+
headerId: "",
552+
footerId: "",
553+
setCalloutWidth: false,
554+
preserveCalloutWidth: false,
555+
maxWindowWidth: 0);
553556
}
554557

555558
private async Task UpdateTime(MouseEventArgs e)

src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,21 +1401,23 @@ private async Task<bool> ToggleCallout()
14011401
if (Standalone) return false;
14021402
if (IsEnabled is false || IsDisposed) return false;
14031403

1404-
return await _js.BitCalloutToggleCallout(_dotnetObj,
1405-
_datePickerId,
1406-
null,
1407-
_calloutId,
1408-
null,
1409-
IsOpen,
1410-
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
1411-
BitDropDirection.TopAndBottom,
1412-
Dir is BitDir.Rtl,
1413-
"",
1414-
0,
1415-
"",
1416-
"",
1417-
false,
1418-
MAX_WIDTH);
1404+
return await _js.BitCalloutToggleCallout(
1405+
dotnetObj: _dotnetObj,
1406+
componentId: _datePickerId,
1407+
component: null,
1408+
calloutId: _calloutId,
1409+
callout: null,
1410+
isCalloutOpen: IsOpen,
1411+
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
1412+
dropDirection: BitDropDirection.TopAndBottom,
1413+
isRtl: Dir is BitDir.Rtl,
1414+
scrollContainerId: "",
1415+
scrollOffset: 0,
1416+
headerId: "",
1417+
footerId: "",
1418+
setCalloutWidth: false,
1419+
preserveCalloutWidth: false,
1420+
maxWindowWidth: MAX_WIDTH);
14191421
}
14201422

14211423
private string GetCalloutCssClasses()

src/BlazorUI/Bit.BlazorUI/Components/Inputs/DateRangePicker/BitDateRangePicker.razor.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,21 +1924,23 @@ private async Task<bool> ToggleCallout()
19241924
if (Standalone) return false;
19251925
if (IsEnabled is false || IsDisposed) return false;
19261926

1927-
return await _js.BitCalloutToggleCallout(_dotnetObj,
1928-
_dateRangePickerId,
1929-
null,
1930-
_calloutId,
1931-
null,
1932-
IsOpen,
1933-
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
1934-
BitDropDirection.TopAndBottom,
1935-
Dir is BitDir.Rtl,
1936-
"",
1937-
0,
1938-
"",
1939-
"",
1940-
false,
1941-
MAX_WIDTH);
1927+
return await _js.BitCalloutToggleCallout(
1928+
dotnetObj: _dotnetObj,
1929+
componentId: _dateRangePickerId,
1930+
component: null,
1931+
calloutId: _calloutId,
1932+
callout: null,
1933+
isCalloutOpen: IsOpen,
1934+
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
1935+
dropDirection: BitDropDirection.TopAndBottom,
1936+
isRtl: Dir is BitDir.Rtl,
1937+
scrollContainerId: "",
1938+
scrollOffset: 0,
1939+
headerId: "",
1940+
footerId: "",
1941+
setCalloutWidth: false,
1942+
preserveCalloutWidth: false,
1943+
maxWindowWidth: MAX_WIDTH);
19421944
}
19431945

19441946
private string GetCalloutCssClasses()

src/BlazorUI/Bit.BlazorUI/Components/Inputs/Dropdown/BitDropdown.razor.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
850850
await base.OnAfterRenderAsync(firstRender);
851851

852852
if (firstRender is false) return;
853-
853+
854854
_dotnetObj = DotNetObjectReference.Create(this);
855855

856856
if (Responsive is false) return;
@@ -1172,20 +1172,23 @@ private async Task ToggleCallout()
11721172
{
11731173
if (IsEnabled is false || IsDisposed) return;
11741174

1175-
_isResponsiveMode = await _js.BitCalloutToggleCallout(_dotnetObj,
1176-
_dropdownId,
1177-
null,
1178-
_calloutId,
1179-
null,
1180-
IsOpen,
1181-
Responsive ? BitResponsiveMode.Panel : BitResponsiveMode.None,
1182-
DropDirection,
1183-
Dir is BitDir.Rtl,
1184-
_scrollContainerId,
1185-
ShowSearchBox && Combo is false ? 32 : 0,
1186-
CalloutHeaderTemplate is not null ? _headerId : "",
1187-
CalloutFooterTemplate is not null ? _footerId : "",
1188-
PreserveCalloutWidth is false);
1175+
_isResponsiveMode = await _js.BitCalloutToggleCallout(
1176+
dotnetObj: _dotnetObj,
1177+
componentId: _dropdownId,
1178+
component: null,
1179+
calloutId: _calloutId,
1180+
callout: null,
1181+
isCalloutOpen: IsOpen,
1182+
responsiveMode: Responsive ? BitResponsiveMode.Panel : BitResponsiveMode.None,
1183+
dropDirection: DropDirection,
1184+
isRtl: Dir is BitDir.Rtl,
1185+
scrollContainerId: _scrollContainerId,
1186+
scrollOffset: ShowSearchBox && Combo is false ? 32 : 0,
1187+
headerId: CalloutHeaderTemplate is not null ? _headerId : "",
1188+
footerId: CalloutFooterTemplate is not null ? _footerId : "",
1189+
setCalloutWidth: PreserveCalloutWidth is false,
1190+
preserveCalloutWidth: false,
1191+
maxWindowWidth: 0);
11891192
}
11901193

11911194
private async ValueTask<ItemsProviderResult<TItem>> InternalItemsProvider(ItemsProviderRequest request)

src/BlazorUI/Bit.BlazorUI/Components/Inputs/SearchBox/BitSearchBox.razor.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,20 +520,23 @@ private async Task ToggleCallout()
520520
{
521521
if (IsEnabled is false || IsDisposed) return;
522522

523-
await _js.BitCalloutToggleCallout(_dotnetObj,
524-
_Id,
525-
null,
526-
_calloutId,
527-
null,
528-
_isOpen,
529-
BitResponsiveMode.None,
530-
BitDropDirection.TopAndBottom,
531-
Dir is BitDir.Rtl,
532-
_scrollContainerId,
533-
0,
534-
string.Empty,
535-
string.Empty,
536-
true);
523+
await _js.BitCalloutToggleCallout(
524+
dotnetObj: _dotnetObj,
525+
componentId: _Id,
526+
component: null,
527+
calloutId: _calloutId,
528+
callout: null,
529+
isCalloutOpen: _isOpen,
530+
responsiveMode: BitResponsiveMode.None,
531+
dropDirection: BitDropDirection.TopAndBottom,
532+
isRtl: Dir is BitDir.Rtl,
533+
scrollContainerId: _scrollContainerId,
534+
scrollOffset: 0,
535+
headerId: string.Empty,
536+
footerId: string.Empty,
537+
setCalloutWidth: false,
538+
preserveCalloutWidth: false,
539+
maxWindowWidth: 0);
537540
}
538541

539542
private async Task ChangeSelectedItem(bool isArrowUp)

src/BlazorUI/Bit.BlazorUI/Components/Inputs/TimePicker/BitTimePicker.razor.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
349349
if (firstRender is false) return;
350350

351351
_dotnetObj = DotNetObjectReference.Create(this);
352-
352+
353353
if (Responsive is false) return;
354354

355355
await _js.BitSwipesSetup(_calloutId, 0.25m, BitPanelPosition.Top, Dir is BitDir.Rtl, BitSwipeOrientation.Vertical, _dotnetObj);
@@ -432,20 +432,23 @@ private async Task ToggleCallout()
432432
if (Standalone) return;
433433
if (IsEnabled is false || IsDisposed) return;
434434

435-
await _js.BitCalloutToggleCallout(_dotnetObj,
436-
_timePickerId,
437-
null,
438-
_calloutId,
439-
null,
440-
IsOpen,
441-
Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
442-
DropDirection,
443-
Dir is BitDir.Rtl,
444-
string.Empty,
445-
0,
446-
string.Empty,
447-
string.Empty,
448-
true);
435+
await _js.BitCalloutToggleCallout(
436+
dotnetObj: _dotnetObj,
437+
componentId: _timePickerId,
438+
component: null,
439+
calloutId: _calloutId,
440+
callout: null,
441+
isCalloutOpen: IsOpen,
442+
responsiveMode: Responsive ? BitResponsiveMode.Top : BitResponsiveMode.None,
443+
dropDirection: DropDirection,
444+
isRtl: Dir is BitDir.Rtl,
445+
scrollContainerId: string.Empty,
446+
scrollOffset: 0,
447+
headerId: string.Empty,
448+
footerId: string.Empty,
449+
setCalloutWidth: true,
450+
preserveCalloutWidth: false,
451+
maxWindowWidth: 0);
449452
}
450453

451454
private async Task HandleOnChange(ChangeEventArgs e)

src/BlazorUI/Bit.BlazorUI/Components/Navs/Breadcrumb/BitBreadcrumb.razor.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -607,20 +607,23 @@ private async Task ToggleCallout()
607607
{
608608
if (IsEnabled is false || IsDisposed) return;
609609

610-
await _js.BitCalloutToggleCallout(_dotnetObj,
611-
_overflowAnchorId,
612-
null,
613-
_calloutId,
614-
null,
615-
_isCalloutOpen,
616-
BitResponsiveMode.None,
617-
BitDropDirection.TopAndBottom,
618-
Dir is BitDir.Rtl,
619-
_scrollContainerId,
620-
0,
621-
"",
622-
"",
623-
false);
610+
await _js.BitCalloutToggleCallout(
611+
dotnetObj: _dotnetObj,
612+
componentId: _overflowAnchorId,
613+
component: null,
614+
calloutId: _calloutId,
615+
callout: null,
616+
isCalloutOpen: _isCalloutOpen,
617+
responsiveMode: BitResponsiveMode.None,
618+
dropDirection: BitDropDirection.TopAndBottom,
619+
isRtl: Dir is BitDir.Rtl,
620+
scrollContainerId: _scrollContainerId,
621+
scrollOffset: 0,
622+
headerId: "",
623+
footerId: "",
624+
setCalloutWidth: false,
625+
preserveCalloutWidth: false,
626+
maxWindowWidth: 0);
624627
}
625628

626629
private string GetItemKey(TItem item, string defaultKey)

src/BlazorUI/Bit.BlazorUI/Components/Navs/DropMenu/BitDropMenu.razor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ await _js.BitCalloutToggleCallout(
218218
headerId: "",
219219
footerId: "",
220220
setCalloutWidth: false,
221+
preserveCalloutWidth: false,
221222
maxWindowWidth: 0);
222223
}
223224

src/BlazorUI/Bit.BlazorUI/Components/Surfaces/Callout/BitCallout.razor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ public partial class BitCallout : BitComponentBase
7979
[Parameter] public EventCallback<bool> OnToggle { get; set; }
8080

8181
/// <summary>
82-
/// Force the callout to set its content container width while openning it based on the available space and actual content.
82+
/// Forces the callout to preserve its component's original width.
83+
/// </summary>
84+
[Parameter] public bool PreserveCalloutWidth { get; set; }
85+
86+
/// <summary>
87+
/// Forces the callout to set its content container width while openning based on the available space and actual content.
8388
/// </summary>
8489
[Parameter] public bool SetCalloutWidth { get; set; }
8590

@@ -200,6 +205,7 @@ await _js.BitCalloutToggleCallout(
200205
headerId: HeaderId ?? "",
201206
footerId: FooterId ?? "",
202207
setCalloutWidth: SetCalloutWidth,
208+
preserveCalloutWidth: PreserveCalloutWidth,
203209
maxWindowWidth: MaxWindowWidth ?? 0);
204210

205211
await OnToggle.InvokeAsync(IsOpen);

0 commit comments

Comments
 (0)