0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 02:50:28 +01:00

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 getUrl = requirejs("discourse-common/lib/get-url").default;
const discourseComputed = requirejs("discourse-common/utils/decorators").default; const discourseComputed = requirejs("discourse-common/utils/decorators").default;
const cook = requirejs("discourse/plugins/discourse-custom-wizard/wizard/lib/text-lite").cook; const cook = requirejs("discourse/plugins/discourse-custom-wizard/wizard/lib/text-lite").cook;
const { schedule } = requirejs("@ember/runloop");
StepModel.reopen({ StepModel.reopen({
save() { save() {
@ -72,8 +73,22 @@ export default {
StepComponent.reopen({ StepComponent.reopen({
classNameBindings: ["step.id"], 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() { animateInvalidFields() {
Ember.run.scheduleOnce("afterRender", () => { schedule("afterRender", () => {
let $element = $(".invalid input[type=text],.invalid textarea,.invalid input[type=checkbox],.invalid .select-kit"); let $element = $(".invalid input[type=text],.invalid textarea,.invalid input[type=checkbox],.invalid .select-kit");
if ($element.length) { if ($element.length) {