1
0
Fork 0

COMPATIBILITY: core autofocus does not work with custom wizard DOM structure

Dieser Commit ist enthalten in:
angus 2021-03-12 18:02:50 +11:00
Ursprung 4edb40e526
Commit ac15ed8983

Datei anzeigen

@ -10,6 +10,7 @@ export default {
const getUrl = requirejs("discourse-common/lib/get-url").default;
const discourseComputed = requirejs("discourse-common/utils/decorators").default;
const cook = requirejs("discourse/plugins/discourse-custom-wizard/wizard/lib/text-lite").cook;
const { schedule } = requirejs("@ember/runloop");
StepModel.reopen({
save() {
@ -71,9 +72,23 @@ export default {
StepComponent.reopen({
classNameBindings: ["step.id"],
autoFocus() {
schedule("afterRender", () => {
const $invalid = $(
".wizard-field.invalid:nth-of-type(1) .wizard-focusable"
);
if ($invalid.length) {
return $invalid.focus();
}
$(".wizard-focusable:first").focus();
});
},
animateInvalidFields() {
Ember.run.scheduleOnce("afterRender", () => {
schedule("afterRender", () => {
let $element = $(".invalid input[type=text],.invalid textarea,.invalid input[type=checkbox],.invalid .select-kit");
if ($element.length) {