Skip to content

Commit 8ced895

Browse files
authored
doc(Template5): add auto focus function (#6490)
* doc(Template5): 更新脚本增加自动获得焦点功能 * chore: add null check
1 parent b6d1fee commit 8ced895

File tree

1 file changed

+15
-0
lines changed
  • src/BootstrapBlazor.Server/Components/Samples/Tutorials/LoginAndRegister

1 file changed

+15
-0
lines changed

src/BootstrapBlazor.Server/Components/Samples/Tutorials/LoginAndRegister/Template5.razor.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
const email = el.querySelector('.login-item-email');
55
if (email) {
66
email.classList.add('show');
7+
const input = email.querySelector('.input');
8+
if (input) {
9+
input.focus();
10+
input.select();
11+
}
712
}
813
}
914
}
@@ -23,6 +28,11 @@ export function go(id) {
2328
password.classList.add('show');
2429
password.classList.add('animate-fade-in')
2530
password.classList.remove('animate-fade-out')
31+
const input = password.querySelector('.input');
32+
if (input) {
33+
input.focus();
34+
input.select();
35+
}
2636
}
2737
}
2838
}
@@ -35,6 +45,11 @@ export function back(id) {
3545
email.classList.add('show');
3646
email.classList.remove('animate-fade-out');
3747
email.classList.add('animate-fade-in');
48+
const input = email.querySelector('.input');
49+
if (input) {
50+
input.focus();
51+
input.select();
52+
}
3853
}
3954

4055
const password = el.querySelector('.login-item-password');

0 commit comments

Comments
 (0)