Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/panels/config/script/ha-script-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,13 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
}

private _aliasChanged(alias: string) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we calculate this on every key stroke and not when the user clicks save ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was our current behavior. We can remove it but they would no longer see the entity ID be created while typing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't realize this was a thing. What weird that we show this to users 🤦

For now this is ok as this fixes the bug then…

if (this.scriptEntityId || this._entityId) {
if (
this.scriptEntityId ||
(this._entityId && this._entityId !== slugify(this._config!.alias))
) {
return;
}

const aliasSlugify = slugify(alias);
let id = aliasSlugify;
let i = 2;
Expand All @@ -595,6 +599,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
private _valueChanged(ev: CustomEvent) {
ev.stopPropagation();
const values = ev.detail.value as any;
const currentId = this._entityId;

for (const key of Object.keys(values)) {
if (key === "sequence") {
Expand All @@ -603,7 +608,10 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {

const value = values[key];

if (value === this._config![key]) {
if (
value === this._config![key] ||
(key === "id" && currentId === value)
) {
continue;
}

Expand Down