Set back focus to the first field in form

This commit is contained in:
Hadi Nategh 2022-05-04 14:14:48 +02:00
parent 9cdfc93a52
commit eecad5f70f
2 changed files with 23 additions and 16 deletions

View File

@ -301,6 +301,8 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
jQuery(self.editor.iframeElement.contentWindow.document).on('dragenter', function(){
if (jQuery('#dragover-tinymce').length < 1) jQuery("<style id='dragover-tinymce'>.dragover:after {height:calc(100% - "+jQuery(this).height()+"px) !important;}</style>").appendTo('head');
});
//set back focus to the first field in the form
self.getInstanceManager().focusOnFirstInput();
}
});
}

View File

@ -681,22 +681,7 @@ export class etemplate2
// Automatically set focus to first visible input for popups
if(this._widgetContainer._egw.is_popup() && jQuery('[autofocus]', this._DOMContainer).focus().length == 0)
{
const $input = jQuery('input:visible', this._DOMContainer)
// Date fields open the calendar popup on focus
.not('.et2_date')
.filter(function()
{
// Skip inputs that are out of tab ordering
const $this = jQuery(this);
return !$this.attr('tabindex') || parseInt($this.attr('tabIndex')) >= 0;
}).first();
// mobile device, focus only if the field is empty (usually means new entry)
// should focus always for non-mobile one
if(egwIsMobile() && $input.val() == "" || !egwIsMobile())
{
$input.focus();
}
this.focusOnFirstInput();
}
// Tell others about it
@ -810,6 +795,26 @@ export class etemplate2
});
}
public focusOnFirstInput()
{
const $input = jQuery('input:visible', this.DOMContainer)
// Date fields open the calendar popup on focus
.not('.et2_date')
.filter(function()
{
// Skip inputs that are out of tab ordering
const $this = jQuery(this);
return !$this.attr('tabindex') || parseInt($this.attr('tabIndex')) >= 0;
}).first();
// mobile device, focus only if the field is empty (usually means new entry)
// should focus always for non-mobile one
if(egwIsMobile() && $input.val() == "" || !egwIsMobile())
{
$input.focus();
}
}
/**
* Check if template contains any dirty (unsaved) content
*