diff --git a/src/panels/logbook/ha-logbook.ts b/src/panels/logbook/ha-logbook.ts
index f72edab10c..91a2890b54 100644
--- a/src/panels/logbook/ha-logbook.ts
+++ b/src/panels/logbook/ha-logbook.ts
@@ -15,7 +15,7 @@ import {
} from "lit-element";
import { HomeAssistant } from "../../types";
import { fireEvent } from "../../common/dom/fire_event";
-import "lit-virtualizer";
+import { scroll } from "lit-virtualizer";
import { LogbookEntry } from "../../data/logbook";
class HaLogbook extends LitElement {
@@ -44,19 +44,23 @@ class HaLogbook extends LitElement {
}
return html`
-
- this._renderLogbookItem(item, index)}
- style="height: 100%;"
- >
+
+ ${scroll({
+ items: this.entries,
+ renderItem: (item: LogbookEntry, index?: number) =>
+ this._renderLogbookItem(item, index),
+ })}
+
`;
}
private _renderLogbookItem(
item: LogbookEntry,
- index: number
+ index?: number
): TemplateResult {
+ if (!index) {
+ return html``;
+ }
const previous = this.entries[index - 1];
const state = item.entity_id ? this.hass.states[item.entity_id] : undefined;
return html`
@@ -149,6 +153,19 @@ class HaLogbook extends LitElement {
a {
color: var(--primary-color);
}
+
+ .uni-virtualizer-host {
+ display: block;
+ position: relative;
+ contain: strict;
+ height: 100%;
+ overflow: auto;
+ padding: 0 16px;
+ }
+
+ .uni-virtualizer-host > * {
+ box-sizing: border-box;
+ }
`;
}
}
diff --git a/src/panels/logbook/ha-panel-logbook.js b/src/panels/logbook/ha-panel-logbook.js
index 3c2c0d0f85..2deaf83a67 100644
--- a/src/panels/logbook/ha-panel-logbook.js
+++ b/src/panels/logbook/ha-panel-logbook.js
@@ -27,10 +27,6 @@ class HaPanelLogbook extends LocalizeMixin(PolymerElement) {
static get template() {
return html`