-
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
Focus on card search input when adding new card #23309
Changes from all 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 | ||||
---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ import "@material/mwc-tab/mwc-tab"; | |||||
import { mdiClose } from "@mdi/js"; | ||||||
import type { CSSResultGroup } from "lit"; | ||||||
import { css, html, LitElement, nothing } from "lit"; | ||||||
import { ifDefined } from "lit/directives/if-defined"; | ||||||
import { customElement, property, state } from "lit/decorators"; | ||||||
import { cache } from "lit/directives/cache"; | ||||||
import { classMap } from "lit/directives/class-map"; | ||||||
|
@@ -60,9 +61,15 @@ export class HuiCreateDialogCard | |||||
|
||||||
@state() private _currTabIndex = 0; | ||||||
|
||||||
@state() private _narrow = false; | ||||||
|
||||||
public async showDialog(params: CreateCardDialogParams): Promise<void> { | ||||||
this._params = params; | ||||||
|
||||||
this._narrow = matchMedia( | ||||||
"all and (max-width: 450px), all and (max-height: 500px)" | ||||||
).matches; | ||||||
|
||||||
const containerConfig = findLovelaceContainer( | ||||||
params.lovelaceConfig, | ||||||
params.path | ||||||
|
@@ -120,7 +127,7 @@ export class HuiCreateDialogCard | |||||
.label=${this.hass!.localize( | ||||||
"ui.panel.lovelace.editor.cardpicker.by_card" | ||||||
)} | ||||||
dialogInitialFocus | ||||||
dialogInitialFocus=${ifDefined(this._narrow ? "" : undefined)} | ||||||
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.
Suggested change
I think this is simpler 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. It is not possible, the dialog searches for an attribute, not for a property |
||||||
></mwc-tab> | ||||||
<mwc-tab | ||||||
.label=${this.hass!.localize( | ||||||
|
@@ -133,6 +140,7 @@ export class HuiCreateDialogCard | |||||
this._currTabIndex === 0 | ||||||
? html` | ||||||
<hui-card-picker | ||||||
dialogInitialFocus=${ifDefined(this._narrow ? undefined : "")} | ||||||
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.
Suggested change
|
||||||
.suggestedCards=${this._params.suggestedCards} | ||||||
.lovelace=${this._params.lovelaceConfig} | ||||||
.hass=${this.hass} | ||||||
|
@@ -143,7 +151,7 @@ export class HuiCreateDialogCard | |||||
<hui-entity-picker-table | ||||||
no-label-float | ||||||
.hass=${this.hass} | ||||||
.narrow=${true} | ||||||
narrow | ||||||
.entities=${this._allEntities(this.hass.states)} | ||||||
@selected-changed=${this._handleSelectedChanged} | ||||||
></hui-entity-picker-table> | ||||||
|
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.
Side note: we should make this a utility function at some point