Repository: dermotduffy/frigate-hass-card (ts)

Issue:
Hidden menu css stays visible even after hidden menu is closed

Pull request description:
Fix menu hide bug causing menu background to stay even when hidden
* Closes #1431 

Patch:
diff --git a/src/components-lib/menu-controller.ts b/src/components-lib/menu-controller.ts
index 0410a340..9f773a56 100644
--- a/src/components-lib/menu-controller.ts
+++ b/src/components-lib/menu-controller.ts
@@ -14,7 +14,7 @@ import {
   frigateCardHandleActionConfig,
   getActionConfigGivenAction,
 } from '../utils/action';
-import { arrayify, isTruthy } from '../utils/basic.js';
+import { arrayify, isTruthy, setOrRemoveAttribute } from '../utils/basic.js';
 import { refreshDynamicStateParameters } from '../utils/ha/index.js';
 
 export class MenuController {
@@ -86,7 +86,7 @@ export class MenuController {
 
   public setExpanded(expanded: boolean): void {
     this._expanded = expanded;
-    this._host.setAttribute('expanded', '');
+    setOrRemoveAttribute(this._host, expanded, 'expanded');
     this._host.requestUpdate();
   }
 


Test patch:
diff --git a/tests/components-lib/menu-controller.test.ts b/tests/components-lib/menu-controller.test.ts
index 596d9312..1467ea47 100644
--- a/tests/components-lib/menu-controller.test.ts
+++ b/tests/components-lib/menu-controller.test.ts
@@ -67,6 +67,22 @@ describe('MenuController', () => {
     expect(host.getAttribute('data-alignment')).toBe('top');
   });
 
+  it('should expand', () => {
+    const host = createLitElement();
+    const controller = new MenuController(host);
+
+    expect(controller.isExpanded()).toBeFalsy();
+    expect(host.getAttribute('expanded')).toBeNull();
+
+    controller.setExpanded(true);
+    expect(controller.isExpanded()).toBeTruthy();
+    expect(host.getAttribute('expanded')).toBe('');
+
+    controller.setExpanded(false);
+    expect(controller.isExpanded()).toBeFalsy();
+    expect(host.getAttribute('expanded')).toBeNull();
+  });
+
   describe('should set and sort buttons', () => {
     it('by priority', () => {
       const controller = new MenuController(createLitElement());