-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix automation picker overflow menu for keyboard #21048
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -822,7 +822,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
</ha-fab> | ||
</hass-tabs-subpage-data-table> | ||
<ha-menu id="overflow-menu" positioning="fixed"> | ||
<ha-menu-item @click=${this._showInfo}> | ||
<ha-menu-item .closeAction=${this._showInfo}> | ||
<ha-svg-icon | ||
.path=${mdiInformationOutline} | ||
slot="start" | ||
|
@@ -832,29 +832,29 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
</div> | ||
</ha-menu-item> | ||
|
||
<ha-menu-item @click=${this._showSettings}> | ||
<ha-menu-item .closeAction=${this._showSettings}> | ||
<ha-svg-icon .path=${mdiCog} slot="start"></ha-svg-icon> | ||
<div slot="headline"> | ||
${this.hass.localize( | ||
"ui.panel.config.automation.picker.show_settings" | ||
)} | ||
</div> | ||
</ha-menu-item> | ||
<ha-menu-item @click=${this._editCategory}> | ||
<ha-menu-item .closeAction=${this._editCategory}> | ||
<ha-svg-icon .path=${mdiTag} slot="start"></ha-svg-icon> | ||
<div slot="headline"> | ||
${this.hass.localize( | ||
`ui.panel.config.automation.picker.${this._overflowAutomation?.category ? "edit_category" : "assign_category"}` | ||
)} | ||
</div> | ||
</ha-menu-item> | ||
<ha-menu-item @click=${this._runActions}> | ||
<ha-menu-item .closeAction=${this._runActions}> | ||
<ha-svg-icon .path=${mdiPlay} slot="start"></ha-svg-icon> | ||
<div slot="headline"> | ||
${this.hass.localize("ui.panel.config.automation.editor.run")} | ||
</div> | ||
</ha-menu-item> | ||
<ha-menu-item @click=${this._showTrace}> | ||
<ha-menu-item .closeAction=${this._showTrace}> | ||
<ha-svg-icon .path=${mdiTransitConnection} slot="start"></ha-svg-icon> | ||
<div slot="headline"> | ||
${this.hass.localize( | ||
|
@@ -863,13 +863,13 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
</div> | ||
</ha-menu-item> | ||
<md-divider role="separator" tabindex="-1"></md-divider> | ||
<ha-menu-item @click=${this._duplicate}> | ||
<ha-menu-item .closeAction=${this._duplicate}> | ||
<ha-svg-icon .path=${mdiContentDuplicate} slot="start"></ha-svg-icon> | ||
<div slot="headline"> | ||
${this.hass.localize("ui.panel.config.automation.picker.duplicate")} | ||
</div> | ||
</ha-menu-item> | ||
<ha-menu-item @click=${this._toggle}> | ||
<ha-menu-item .closeAction=${this._toggle}> | ||
<ha-svg-icon | ||
.path=${ | ||
this._overflowAutomation?.state === "off" | ||
|
@@ -888,7 +888,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
} | ||
</div> | ||
</ha-menu-item> | ||
<ha-menu-item @click=${this._deleteConfirm} class="warning"> | ||
<ha-menu-item .closeAction=${this._deleteConfirm} class="warning"> | ||
<ha-svg-icon .path=${mdiDelete} slot="start"></ha-svg-icon> | ||
<div slot="headline"> | ||
${this.hass.localize("ui.panel.config.automation.picker.delete")} | ||
|
@@ -1051,28 +1051,28 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
this._applyFilters(); | ||
} | ||
|
||
private _showInfo(ev) { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _showInfo = (ev) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...then type the parameter as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will say that typing this is getting kind of ugly. I have to cast the parent element, then cast the anchorElement back to
Is this going to be acceptable or need to clean it up somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine for now. The best goal would be to turn on |
||
const automation = ev.currentTarget.anchorElement.automation; | ||
fireEvent(this, "hass-more-info", { entityId: automation.entity_id }); | ||
} | ||
}; | ||
karwosts marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private _showSettings(ev) { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _showSettings = (ev) => { | ||
const automation = ev.currentTarget.anchorElement.automation; | ||
|
||
fireEvent(this, "hass-more-info", { | ||
entityId: automation.entity_id, | ||
view: "settings", | ||
}); | ||
} | ||
}; | ||
|
||
private _runActions(ev) { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _runActions = (ev) => { | ||
const automation = ev.currentTarget.anchorElement.automation; | ||
|
||
triggerAutomationActions(this.hass, automation.entity_id); | ||
} | ||
}; | ||
|
||
private _editCategory(ev) { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _editCategory = (ev) => { | ||
const automation = ev.currentTarget.anchorElement.automation; | ||
|
||
const entityReg = this._entityReg.find( | ||
(reg) => reg.entity_id === automation.entity_id | ||
|
@@ -1092,10 +1092,10 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
scope: "automation", | ||
entityReg, | ||
}); | ||
} | ||
}; | ||
|
||
private _showTrace(ev) { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _showTrace = (ev) => { | ||
const automation = ev.currentTarget.anchorElement.automation; | ||
|
||
if (!automation.attributes.id) { | ||
showAlertDialog(this, { | ||
|
@@ -1108,19 +1108,19 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
navigate( | ||
`/config/automation/trace/${encodeURIComponent(automation.attributes.id)}` | ||
); | ||
} | ||
}; | ||
|
||
private async _toggle(ev): Promise<void> { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _toggle = async (ev): Promise<void> => { | ||
const automation = ev.currentTarget.anchorElement.automation; | ||
|
||
const service = automation.state === "off" ? "turn_on" : "turn_off"; | ||
await this.hass.callService("automation", service, { | ||
entity_id: automation.entity_id, | ||
}); | ||
} | ||
}; | ||
|
||
private async _deleteConfirm(ev) { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _deleteConfirm = async (ev) => { | ||
const automation = ev.currentTarget.anchorElement.automation; | ||
|
||
showConfirmationDialog(this, { | ||
title: this.hass.localize( | ||
|
@@ -1135,7 +1135,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
confirm: () => this._delete(automation), | ||
destructive: true, | ||
}); | ||
} | ||
}; | ||
|
||
private async _delete(automation) { | ||
try { | ||
|
@@ -1155,8 +1155,8 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
} | ||
} | ||
|
||
private async _duplicate(ev) { | ||
const automation = ev.currentTarget.parentElement.anchorElement.automation; | ||
private _duplicate = async (ev) => { | ||
const automation = ev.currentTarget.anchorElement.automation; | ||
|
||
try { | ||
const config = await fetchAutomationFileConfig( | ||
|
@@ -1180,7 +1180,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) { | |
), | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
private _showHelp() { | ||
showAlertDialog(this, { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions to improve the API:
clickAction
or justaction
. @bramkragten any strong opinion here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should be passed as the
item
here, theev.detail.initiator
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes