[IMP] web: extend form default autofocus to textarea and contenteditable
When rendering, the form view looks for the element it should autofocus, and defaults to the first text input it finds. This extends that default behavior to the first textarea or contenteditable element. closes odoo/odoo#106622 X-original-commit: 82a98715ae2937bff8b58212c452a28d0b28e102 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -49,9 +49,10 @@ export class FormRenderer extends Component {
|
||||
}
|
||||
let elementToFocus;
|
||||
if (isVirtual) {
|
||||
const focusableSelectors = ['input[type="text"]', 'textarea', '[contenteditable]'];
|
||||
elementToFocus =
|
||||
(autofocusFieldId && rootEl.querySelector(`#${autofocusFieldId}`)) ||
|
||||
rootEl.querySelector(`.o_content .o_field_widget input[type="text"]`);
|
||||
rootEl.querySelector(focusableSelectors.map(sel => `.o_content .o_field_widget ${sel}`).join(', '));
|
||||
}
|
||||
if (elementToFocus) {
|
||||
elementToFocus.focus();
|
||||
|
||||
Reference in New Issue
Block a user