fix: focus on first input only if needed (#22212)
This commit is contained in:
parent
07ff74edc5
commit
e71c5142cf
1 changed files with 11 additions and 3 deletions
|
|
@ -647,10 +647,18 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
}
|
||||
|
||||
focus_on_first_input() {
|
||||
let first = this.form_wrapper.find(".form-layout :input:visible:first");
|
||||
if (!in_list(["Date", "Datetime"], first.attr("data-fieldtype"))) {
|
||||
first.focus();
|
||||
const layout_wrapper = this.layout.wrapper;
|
||||
|
||||
// dont do anything if the current active element is inside the form
|
||||
// user must have clicked on some element before this function trigerred
|
||||
if (!layout_wrapper || layout_wrapper.has(":focus").length) {
|
||||
return;
|
||||
}
|
||||
|
||||
layout_wrapper
|
||||
.find(":input:visible:first")
|
||||
.not("[data-fieldtype^='Date']")
|
||||
.trigger("focus");
|
||||
}
|
||||
|
||||
run_after_load_hook() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue