mirror of
https://github.com/lemeow125/Ivy-Backend.git
synced 2024-11-17 14:49:25 +08:00
17 lines
606 B
JavaScript
17 lines
606 B
JavaScript
|
'use strict';
|
||
|
{
|
||
|
const inputTags = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'];
|
||
|
const modelName = document.getElementById('django-admin-form-add-constants').dataset.modelName;
|
||
|
if (modelName) {
|
||
|
const form = document.getElementById(modelName + '_form');
|
||
|
for (const element of form.elements) {
|
||
|
// HTMLElement.offsetParent returns null when the element is not
|
||
|
// rendered.
|
||
|
if (inputTags.includes(element.tagName) && !element.disabled && element.offsetParent) {
|
||
|
element.focus();
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|