diff --git a/app/assets/javascripts/discourse/app/form-kit/components/fk/control-wrapper.gjs b/app/assets/javascripts/discourse/app/form-kit/components/fk/control-wrapper.gjs index 9adcaf6abbd..07681c888ec 100644 --- a/app/assets/javascripts/discourse/app/form-kit/components/fk/control-wrapper.gjs +++ b/app/assets/javascripts/discourse/app/form-kit/components/fk/control-wrapper.gjs @@ -1,6 +1,6 @@ import Component from "@glimmer/component"; -import { concat } from "@ember/helper"; -import { action } from "@ember/object"; +import { concat, fn } from "@ember/helper"; +import willDestroy from "@ember/render-modifiers/modifiers/will-destroy"; import { eq } from "truth-helpers"; import FKLabel from "discourse/form-kit/components/fk/label"; import FKMeta from "discourse/form-kit/components/fk/meta"; @@ -9,12 +9,6 @@ import concatClass from "discourse/helpers/concat-class"; import { i18n } from "discourse-i18n"; export default class FKControlWrapper extends Component { - constructor() { - super(...arguments); - - this.args.field.setType(this.controlType); - } - get controlType() { if (this.args.component.controlType === "input") { return this.args.component.controlType + "-" + (this.args.type || "text"); @@ -23,11 +17,6 @@ export default class FKControlWrapper extends Component { return this.args.component.controlType; } - @action - setFieldType() { - this.args.field.type = this.controlType; - } - get error() { return (this.args.errors ?? {})[this.args.field.name]; } @@ -44,12 +33,13 @@ export default class FKControlWrapper extends Component { "form-kit__field" (concat "form-kit__field-" this.controlType) (if this.error "has-error") - (if @disabled "is-disabled") - (if (eq @format "full") "--full") + (if @field.disabled "is-disabled") + (if (eq @field.format "full") "--full") }} - data-disabled={{@disabled}} + data-disabled={{@field.disabled}} data-name={{@field.name}} data-control-type={{this.controlType}} + {{willDestroy (fn @unregisterField @field.name)}} > {{#if @field.showTitle}} @@ -72,7 +62,7 @@ export default class FKControlWrapper extends Component {
<@component @@ -86,7 +76,6 @@ export default class FKControlWrapper extends Component { @after={{@after}} @height={{@height}} @selection={{@selection}} - @disabled={{@disabled}} id={{@field.id}} name={{@field.name}} aria-invalid={{if this.error "true"}} @@ -97,12 +86,7 @@ export default class FKControlWrapper extends Component { {{yield components}} - +
diff --git a/app/assets/javascripts/discourse/app/form-kit/components/fk/control/checkbox.gjs b/app/assets/javascripts/discourse/app/form-kit/components/fk/control/checkbox.gjs index 50ee04db14b..eecb2d11de2 100644 --- a/app/assets/javascripts/discourse/app/form-kit/components/fk/control/checkbox.gjs +++ b/app/assets/javascripts/discourse/app/form-kit/components/fk/control/checkbox.gjs @@ -9,21 +9,23 @@ export default class FKControlCheckbox extends Component { @action handleInput() { - this.args.field.set(!this.args.value); + this.args.field.set(!this.args.field.value); }