Skip to content

Commit 1ef1030

Browse files
authored
fix(ValidateForm): show first element tooltip when set ShowAllInvalidResult to false (#4332)
* refactor: 更新寻找报错组件逻辑 * chore: bump version 8.9.3-beta02
1 parent d8b0458 commit 1ef1030

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>8.9.3-beta01</Version>
4+
<Version>8.9.3-beta02</Version>
55
</PropertyGroup>
66

77
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ export function init(id) {
1616

1717
export function update(id, invalidIds) {
1818
const el = document.getElementById(id);
19-
const items = [...el.children];
19+
const items = [...el.querySelectorAll(".is-invalid")];
2020
const invalidElements = invalidIds.map(cId => {
2121
const item = document.getElementById(cId);
22-
let parentEl = item.parentElement;
23-
while (parentEl !== el) {
24-
parentEl = parentEl.parentElement;
22+
let order = items.indexOf(item);
23+
if (order === -1) {
24+
const invalidEl = item.querySelector(".is-invalid");
25+
if (invalidEl) {
26+
order = items.indexOf(invalidEl);
27+
}
2528
}
26-
return {
27-
item, order: items.indexOf(item)
28-
};
29+
return { item, order };
2930
});
3031
invalidElements.sort((a, b) => b.order - a.order);
3132

0 commit comments

Comments
 (0)