Skip to content

A platform for community discussion. Free, open, simple.

DEV: adds is-disabled modifier to form field container (#29567)

Joffrey JAFFEUX584a9d98ed11
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 e34cda32aff..f30d352923d 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
@@ -44,6 +44,7 @@ export default class FKControlWrapper extends Component {
"form-kit__field"
(concat "form-kit__field-" this.controlType)
(if this.error "has-error")
+ (if @field.disabled "is-disabled")
(if (eq @format "full") "--full")
}}
data-disabled={{@field.disabled}}
diff --git a/app/assets/javascripts/discourse/tests/integration/components/form-kit/field-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/form-kit/field-test.gjs
index 54736c3eaa9..dd7382da1e9 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/form-kit/field-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/form-kit/field-test.gjs
@@ -35,6 +35,20 @@ module("Integration | Component | FormKit | Field", function (hooks) {
assert.dom(".form-kit__row .form-kit__col.--col-8").hasText("Test");
});
+ test("@disabled", async function (assert) {
+ await render(<template>
+ <Form as |form|>
+ <form.Field @name="foo" @title="Foo" @disabled={{true}} as |field|>
+ <field.Input />
+ </form.Field>
+ </Form>
+ </template>);
+
+ assert
+ .dom("#control-foo.is-disabled[data-disabled]")
+ .exists("it sets the disabled class and data attribute");
+ });
+
test("@description", async function (assert) {
await render(<template>
<Form as |form|>