diff --git a/custom_components/bahmcloud_store/panel/panel.js b/custom_components/bahmcloud_store/panel/panel.js index a065331..ef0a588 100644 --- a/custom_components/bahmcloud_store/panel/panel.js +++ b/custom_components/bahmcloud_store/panel/panel.js @@ -169,7 +169,7 @@ class BahmcloudStorePanel extends HTMLElement { `bcs/readme?repo_id=${encodeURIComponent(repoId)}` ); - if (resp?.ok && typeof resp.readme === "string") { + if (resp?.ok && typeof resp.readme === "string" && resp.readme.trim()) { this._readmeText = resp.readme; } else { this._readmeText = null; @@ -294,14 +294,14 @@ class BahmcloudStorePanel extends HTMLElement { margin-bottom: 12px; } - input, select{ + input, select, textarea{ padding:10px 12px; border-radius:12px; border:1px solid var(--divider-color); background:var(--card-background-color); color:var(--primary-text-color); outline:none; } - input:focus, select:focus{ + input:focus, select:focus, textarea:focus{ border-color:var(--bcs-accent); box-shadow:0 0 0 2px color-mix(in srgb, var(--bcs-accent) 20%, transparent); } @@ -341,18 +341,15 @@ class BahmcloudStorePanel extends HTMLElement { opacity: .55; cursor: not-allowed; } - .fab-label{ - position: fixed; - right: 84px; - bottom: 18px; - display: none; - } - .mdwrap ha-markdown{ - display: block; - } - .mdwrap{ - padding-top: 6px; + /* README fallback pre */ + pre.readme{ + white-space: pre-wrap; + word-break: break-word; + margin: 0; + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + font-size: 12.5px; + line-height: 1.5; } @@ -394,6 +391,29 @@ class BahmcloudStorePanel extends HTMLElement { this._update(); }); } + + // ✅ CRITICAL FIX: prevent HA global shortcuts (Assist/Command Palette) from + // stealing keystrokes while typing in inputs inside this panel. + const stopIfFormField = (e) => { + const t = e.composedPath ? e.composedPath()[0] : e.target; + if (!t) return; + + const tag = (t.tagName || "").toLowerCase(); + const isEditable = + tag === "input" || + tag === "textarea" || + tag === "select" || + t.isContentEditable; + + if (isEditable) { + e.stopPropagation(); + } + }; + + // Use capture phase so we intercept before HA handlers. + root.addEventListener("keydown", stopIfFormField, true); + root.addEventListener("keyup", stopIfFormField, true); + root.addEventListener("keypress", stopIfFormField, true); } _update() { @@ -406,14 +426,12 @@ class BahmcloudStorePanel extends HTMLElement { const v = this._data?.version ? String(this._data.version) : null; subtitle.textContent = v ? `BCS ${v}` : "BCS — loading…"; - // Tabs active state (detail is not a tab) for (const tab of root.querySelectorAll(".tab")) { tab.classList.toggle("active", tab.getAttribute("data-view") === this._view); } err.textContent = this._error ? `Error: ${this._error}` : ""; - // FABs only on detail view fabs.innerHTML = this._view === "detail" ? this._renderFabs() : ""; this._wireFabs(); @@ -560,8 +578,10 @@ class BahmcloudStorePanel extends HTMLElement { ? `
const root = this.shadowRoot;
- const mdEl = root.getElementById("readmeMd");
- if (mdEl && this._readmeText) {
- try {
- mdEl.hass = this._hass;
- } catch (_) {}
- mdEl.content = this._readmeText;
+ const container = root.getElementById("readmeContainer");
+ if (!container) return;
+
+ container.innerHTML = "";
+
+ if (!this._readmeText) return;
+
+ // Try HA markdown element (best effort)
+ try {
+ const el = document.createElement("ha-markdown");
+ // some HA builds need hass set before content
+ try { el.hass = this._hass; } catch (_) {}
+ el.content = this._readmeText;
+ container.appendChild(el);
+ return;
+ } catch (_) {
+ // fall through
}
+
+ // Fallback: raw text
+ const pre = document.createElement("pre");
+ pre.className = "readme";
+ pre.textContent = this._readmeText;
+ container.appendChild(pre);
}
_renderFabs() {