FIX: Don't throw errors on wizard dropdowns (#16994)

This commit is contained in:
Jarek Radosz 2022-06-04 18:04:00 +02:00 committed by GitHub
parent 17227e9e53
commit f4b9d4e285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 21 deletions

View File

@ -4,7 +4,7 @@ import {
darkLightDiff, darkLightDiff,
} from "wizard/lib/preview"; } from "wizard/lib/preview";
import I18n from "I18n"; import I18n from "I18n";
import { observes } from "discourse-common/utils/decorators"; import { bind, observes } from "discourse-common/utils/decorators";
const LOREM = ` const LOREM = `
Lorem ipsum dolor sit amet, consectetur adipiscing. Lorem ipsum dolor sit amet, consectetur adipiscing.
@ -20,6 +20,16 @@ export default createPreviewComponent(659, 320, {
startX: 0, startX: 0,
scrollLeft: 0, scrollLeft: 0,
init() {
this._super(...arguments);
this.wizard.on("homepageStyleChanged", this.onHomepageStyleChange);
},
willDestroy() {
this._super(...arguments);
this.wizard.off("homepageStyleChanged", this.onHomepageStyleChange);
},
mouseDown(e) { mouseDown(e) {
const slider = this.element.querySelector(".previews"); const slider = this.element.querySelector(".previews");
this.setProperties({ this.setProperties({
@ -61,10 +71,11 @@ export default createPreviewComponent(659, 320, {
this._super(...arguments); this._super(...arguments);
this.triggerRepaint(); this.triggerRepaint();
},
if (this.stylingDropdown?.id === "homepage_style") { @bind
onHomepageStyleChange() {
this.set("previewTopic", false); this.set("previewTopic", false);
}
}, },
@observes("previewTopic") @observes("previewTopic")

View File

@ -30,7 +30,10 @@ export default Component.extend({
actions: { actions: {
onChangeValue(value) { onChangeValue(value) {
this.set("field.value", value); this.set("field.value", value);
this.stylingDropdownChanged(this.field.id, value);
if (this.field.id === "homepage_style") {
this.wizard.trigger("homepageStyleChanged");
}
}, },
}, },
}); });

View File

@ -11,11 +11,6 @@ export default Component.extend({
classNames: ["wizard-step"], classNames: ["wizard-step"],
saving: null, saving: null,
init() {
this._super(...arguments);
this.set("stylingDropdown", {});
},
didInsertElement() { didInsertElement() {
this._super(...arguments); this._super(...arguments);
this.autoFocus(); this.autoFocus();
@ -117,10 +112,6 @@ export default Component.extend({
document.location = getUrl("/"); document.location = getUrl("/");
}, },
stylingDropdownChanged(id, value) {
this.set("stylingDropdown", { id, value });
},
exitEarly() { exitEarly() {
const step = this.step; const step = this.step;
step.validate(); step.validate();

View File

@ -1,10 +1,11 @@
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import Evented from "@ember/object/evented";
import Step from "wizard/models/step"; import Step from "wizard/models/step";
import WizardField from "wizard/models/wizard-field"; import WizardField from "wizard/models/wizard-field";
import { ajax } from "wizard/lib/ajax"; import { ajax } from "wizard/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
const Wizard = EmberObject.extend({ const Wizard = EmberObject.extend(Evented, {
@discourseComputed("steps.length") @discourseComputed("steps.length")
totalSteps: (length) => length, totalSteps: (length) => length,

View File

@ -7,7 +7,6 @@
{{homepage-preview {{homepage-preview
wizard=wizard wizard=wizard
step=step step=step
stylingDropdown=stylingDropdown
}} }}
</div> </div>
</div> </div>

View File

@ -15,11 +15,10 @@
<div class="input-area"> <div class="input-area">
{{component {{component
inputComponentName inputComponentName
field=field step=step field=field
step=step
fieldClass=fieldClass fieldClass=fieldClass
wizard=wizard wizard=wizard
stylingDropdownChanged=stylingDropdownChanged
stylingDropdown=stylingDropdown
}} }}
</div> </div>

View File

@ -22,7 +22,6 @@
field=field field=field
step=step step=step
wizard=wizard wizard=wizard
stylingDropdownChanged=(action "stylingDropdownChanged")
}} }}
{{/if}} {{/if}}
{{/each}} {{/each}}
@ -35,7 +34,6 @@
field=field field=field
step=step step=step
wizard=wizard wizard=wizard
stylingDropdown=stylingDropdown
}} }}
{{/unless}} {{/unless}}
{{/each}} {{/each}}