mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
fix read-only fields in config flow expandables (#28579)
* fix read-only fields in config flow expandables * types --------- Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
@@ -50,14 +50,27 @@ class StepFlowForm extends LitElement {
|
||||
this.removeEventListener("keydown", this._handleKeyDown);
|
||||
}
|
||||
|
||||
private handleReadOnlyFields = memoizeOne((schema) =>
|
||||
schema?.map((field) => ({
|
||||
private handleReadOnlyFields = memoizeOne((schema) => {
|
||||
function handleReadOnlyField(field: HaFormSchema) {
|
||||
return {
|
||||
...field,
|
||||
...(Object.values((field as HaFormSelector)?.selector ?? {})[0]?.read_only
|
||||
...(Object.values((field as HaFormSelector)?.selector ?? {})[0]
|
||||
?.read_only
|
||||
? { disabled: true }
|
||||
: {}),
|
||||
}))
|
||||
};
|
||||
}
|
||||
return schema?.map((field: HaFormSchema) =>
|
||||
field.type === "expandable" && field.schema
|
||||
? {
|
||||
...field,
|
||||
schema: field.schema.map((sectionField) =>
|
||||
handleReadOnlyField(sectionField)
|
||||
),
|
||||
}
|
||||
: handleReadOnlyField(field)
|
||||
);
|
||||
});
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const step = this.step;
|
||||
|
||||
Reference in New Issue
Block a user