Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.4.3-beta01</Version>
<Version>9.4.3-beta02</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
data-bs-toggle="@ToggleString" data-bs-placement="@PlacementString"
data-bs-offset="@OffsetString" data-bs-custom-class="@CustomClassString"
data-bb-auto-dropdown-focus="@ShowDropdownListOnFocusString" data-bb-debounce="@DurationString"
data-bb-skip-esc="@SkipEscString" data-bb-skip-enter="@SkipEnterString"
data-bb-skip-esc="@SkipEscString" data-bb-skip-enter="@SkipEnterString" data-bb-blur="@TriggerBlurString"
data-bb-scroll-behavior="@ScrollIntoViewBehaviorString"
value="@CurrentValueAsString"
placeholder="@PlaceHolder" disabled="@Disabled" @ref="FocusElement"/>
Expand Down
22 changes: 11 additions & 11 deletions src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export function init(id, invoke) {
})
}

EventHandler.on(input, 'blur', e => {
el.classList.remove('show');
const triggerBlur = input.getAttribute('data-bb-blur') === 'true';
if (triggerBlur) {
invoke.invokeMethodAsync('TriggerBlur');
}
});

EventHandler.on(input, 'focus', e => {
const showDropdownOnFocus = input.getAttribute('data-bb-auto-dropdown-focus') === 'true';
if (showDropdownOnFocus) {
Expand All @@ -46,14 +54,6 @@ export function init(id, invoke) {
}
});

EventHandler.on(menu, 'click', e => {
el.classList.remove('show');
if (el.triggerEnter !== true) {
invoke.invokeMethodAsync('TriggerBlur');
}
delete el.triggerEnter;
});

EventHandler.on(input, 'change', e => {
invoke.invokeMethodAsync('TriggerChange', e.target.value);
});
Expand Down Expand Up @@ -113,17 +113,17 @@ const handlerKeyup = (ac, e) => {
if (!skipEnter) {
const current = menu.querySelector('.active');
if (current !== null) {
el.triggerEnter = true;
current.click();
input.blur();
}
invoke.invokeMethodAsync('EnterCallback', input.value);
}
}
else if (key === 'Escape') {
const skipEsc = el.getAttribute('data-bb-skip-esc') === 'true';
if (skipEsc === false) {
EventHandler.trigger(menu, 'click');
invoke.invokeMethodAsync('EscCallback');
input.blur();
}
}
else if (key === 'ArrowUp' || key === 'ArrowDown') {
Expand Down Expand Up @@ -172,7 +172,7 @@ export function dispose(id) {
}
}
EventHandler.off(input, 'keyup');
EventHandler.off(menu, 'click');
EventHandler.off(input, 'blur');
Input.dispose(input);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public abstract class PopoverCompleteBase<TValue> : BootstrapInputBase<TValue>,
/// </summary>
protected string? SkipEnterString => SkipEnter ? "true" : null;

/// <summary>
/// 获得 是否跳过 Blur 处理字符串
/// </summary>
protected string? TriggerBlurString => OnBlurAsync != null ? "true" : null;

/// <summary>
/// 获得 滚动行为字符串
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Search/Search.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
data-bs-toggle="@ToggleString" data-bs-placement="@PlacementString"
data-bs-offset="@OffsetString" data-bs-custom-class="@CustomClassString"
data-bb-auto-dropdown-focus="@ShowDropdownListOnFocusString" data-bb-debounce="@DurationString"
data-bb-skip-esc="@SkipEscString" data-bb-skip-enter="@SkipEnterString"
data-bb-skip-esc="@SkipEscString" data-bb-skip-enter="@SkipEnterString" data-bb-blur="@TriggerBlurString"
data-bb-scroll-behavior="@ScrollIntoViewBehaviorString"
data-bb-input="@UseInputString"
value="@_displayText"
Expand Down