COMPATIBILITY: core autofocus does not work with custom wizard DOM structure
Dieser Commit ist enthalten in:
Ursprung
4edb40e526
Commit
ac15ed8983
1 geänderte Dateien mit 16 neuen und 1 gelöschten Zeilen
|
@ -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) {
|
||||||
|
|
Laden …
In neuem Issue referenzieren