@@ -14,7 +14,7 @@ import {
1414import type { HassEntity } from "home-assistant-js-websocket" ;
1515import type { PropertyValues } from "lit" ;
1616import { LitElement , css , html , nothing } from "lit" ;
17- import { customElement , property , state } from "lit/decorators" ;
17+ import { customElement , property , query , state } from "lit/decorators" ;
1818import { cache } from "lit/directives/cache" ;
1919import { keyed } from "lit/directives/keyed" ;
2020import { dynamicElement } from "../../common/dom/dynamic-element-directive" ;
@@ -50,7 +50,12 @@ import { lightSupportsFavoriteColors } from "../../data/light";
5050import type { ItemType } from "../../data/search" ;
5151import { SearchableDomains } from "../../data/search" ;
5252import { getSensorNumericDeviceClasses } from "../../data/sensor" ;
53- import { haStyleDialog , haStyleDialogFixedTop } from "../../resources/styles" ;
53+ import { ScrollableFadeMixin } from "../../mixins/scrollable-fade-mixin" ;
54+ import {
55+ haStyleDialog ,
56+ haStyleDialogFixedTop ,
57+ haStyleScrollbar ,
58+ } from "../../resources/styles" ;
5459import "../../state-summary/state-card-content" ;
5560import type { HomeAssistant } from "../../types" ;
5661import {
@@ -96,13 +101,15 @@ declare global {
96101const DEFAULT_VIEW : View = "info" ;
97102
98103@customElement ( "ha-more-info-dialog" )
99- export class MoreInfoDialog extends LitElement {
104+ export class MoreInfoDialog extends ScrollableFadeMixin ( LitElement ) {
100105 @property ( { attribute : false } ) public hass ! : HomeAssistant ;
101106
102107 @property ( { type : Boolean , reflect : true } ) public large = false ;
103108
104109 @state ( ) private _parentEntityIds : string [ ] = [ ] ;
105110
111+ @query ( ".content" ) private _contentElement ?: HTMLDivElement ;
112+
106113 @state ( ) private _entityId ?: string | null ;
107114
108115 @state ( ) private _data ?: Record < string , any > ;
@@ -121,6 +128,12 @@ export class MoreInfoDialog extends LitElement {
121128
122129 @state ( ) private _sensorNumericDeviceClasses ?: string [ ] = [ ] ;
123130
131+ protected scrollFadeThreshold = 24 ;
132+
133+ protected get scrollableElement ( ) : HTMLElement | null {
134+ return this . _contentElement || null ;
135+ }
136+
124137 public showDialog ( params : MoreInfoDialogParams ) {
125138 this . _entityId = params . entityId ;
126139 if ( ! this . _entityId ) {
@@ -594,78 +607,81 @@ export class MoreInfoDialog extends LitElement {
594607 `
595608 : nothing }
596609 </ ha- dialog- header>
597- ${ keyed (
598- this . _entityId ,
599- html `
600- <div
601- class= "content"
602- tabindex = "-1"
603- dialogInitialFocus
604- @show-child-view = ${ this . _showChildView }
605- @entity-entry-updated = ${ this . _entryUpdated }
606- @toggle-edit-mode = ${ this . _handleToggleInfoEditModeEvent }
607- @hass-more-info = ${ this . _handleMoreInfoEvent }
608- >
609- ${ cache (
610- this . _childView
611- ? html `
612- <div class= "child-view" >
613- ${ dynamicElement ( this . _childView . viewTag , {
614- hass : this . hass ,
615- entry : this . _entry ,
616- params : this . _childView . viewParams ,
617- } ) }
618- </ div>
619- `
620- : this . _currView === "info"
610+ <div class= "content-wrapper" >
611+ ${ keyed (
612+ this . _entityId ,
613+ html `
614+ <div
615+ class= "content ha-scrollbar"
616+ tabindex = "-1"
617+ dialogInitialFocus
618+ @show-child-view = ${ this . _showChildView }
619+ @entity-entry-updated = ${ this . _entryUpdated }
620+ @toggle-edit-mode = ${ this . _handleToggleInfoEditModeEvent }
621+ @hass-more-info = ${ this . _handleMoreInfoEvent }
622+ >
623+ ${ cache (
624+ this . _childView
621625 ? html `
622- <ha- mor e-info- info
623- dialogInitialFocus
624- .hass = ${ this . hass }
625- .entityId = ${ this . _entityId }
626- .entry = ${ this . _entry }
627- .editMode = ${ this . _infoEditMode }
628- .data = ${ this . _data }
629- > </ ha- mor e-info- info>
626+ <div class= "child-view" >
627+ ${ dynamicElement ( this . _childView . viewTag , {
628+ hass : this . hass ,
629+ entry : this . _entry ,
630+ params : this . _childView . viewParams ,
631+ } ) }
632+ </ div>
630633 `
631- : this . _currView === "history "
634+ : this . _currView === "info "
632635 ? html `
633- <ha- mor e-info- his to ry- and - logbook
636+ <ha- mor e-info- info
637+ dialogInitialFocus
634638 .hass = ${ this . hass }
635639 .entityId = ${ this . _entityId }
636- > </ ha- mor e-info- his to ry- and - logbook>
640+ .entry = ${ this . _entry }
641+ .editMode = ${ this . _infoEditMode }
642+ .data = ${ this . _data }
643+ > </ ha- mor e-info- info>
637644 `
638- : this . _currView === "settings "
645+ : this . _currView === "history "
639646 ? html `
640- <ha- mor e-info- settings
647+ <ha- mor e-info- h is to ry - and - logbook
641648 .hass = ${ this . hass }
642649 .entityId = ${ this . _entityId }
643- .entry = ${ this . _entry }
644- > </ ha- mor e-info- settings>
650+ > </ ha- mor e-info- his to ry- and - logbook>
645651 `
646- : this . _currView === "related "
652+ : this . _currView === "settings "
647653 ? html `
648- <ha- related - items
654+ <ha- m or e-info - settings
649655 .hass = ${ this . hass }
650- .itemId = ${ entityId }
651- .itemType = ${ SearchableDomains . has ( domain )
652- ? ( domain as ItemType )
653- : "entity" }
654- > </ ha- related- items>
656+ .entityId = ${ this . _entityId }
657+ .entry = ${ this . _entry }
658+ > </ ha- mor e-info- settings>
655659 `
656- : this . _currView === "add_to "
660+ : this . _currView === "related "
657661 ? html `
658- <ha- m or e-info - add - to
662+ <ha- related - items
659663 .hass = ${ this . hass }
660- .entityId = ${ entityId }
661- @add-to-action-selected = ${ this . _goBack }
662- > </ ha- mor e-info- add- to >
664+ .itemId = ${ entityId }
665+ .itemType = ${ SearchableDomains . has ( domain )
666+ ? ( domain as ItemType )
667+ : "entity" }
668+ > </ ha- related- items>
663669 `
664- : nothing
665- ) }
666- </ div>
667- `
668- ) }
670+ : this . _currView === "add_to"
671+ ? html `
672+ <ha- mor e-info- add- to
673+ .hass = ${ this . hass }
674+ .entityId = ${ entityId }
675+ @add-to-action-selected = ${ this . _goBack }
676+ > </ ha- mor e-info- add- to >
677+ `
678+ : nothing
679+ ) }
680+ </ div>
681+ `
682+ ) }
683+ ${ this . renderScrollableFades ( ) }
684+ </ div>
669685 </ ha- dialog>
670686 ` ;
671687 }
@@ -720,18 +736,27 @@ export class MoreInfoDialog extends LitElement {
720736
721737 static get styles ( ) {
722738 return [
739+ ...super . styles ,
723740 haStyleDialog ,
724741 haStyleDialogFixedTop ,
742+ haStyleScrollbar ,
725743 css `
726744 ha-dialog {
727745 --dialog-content-padding : 0 ;
728746 }
729747
730- .content {
748+ .content-wrapper {
749+ flex : 1 1 auto;
750+ min-height : 0 ;
751+ position : relative;
731752 display : flex;
732753 flex-direction : column;
754+ }
755+
756+ .content {
733757 outline : none;
734758 flex : 1 ;
759+ overflow : auto;
735760 }
736761
737762 .child-view {
0 commit comments