فهرست منبع

fix(tui): stop disabled tab pulse rendering (#42346)

Kit Langton 3 روز پیش
والد
کامیت
4836356c17
2فایلهای تغییر یافته به همراه25 افزوده شده و 1 حذف شده
  1. 1 1
      packages/tui/src/component/tab-pulse.tsx
  2. 24 0
      packages/tui/test/component/tab-pulse.test.tsx

+ 1 - 1
packages/tui/src/component/tab-pulse.tsx

@@ -190,7 +190,7 @@ class PulseState {
   }
 
   get live() {
-    return this.active || this.breathing || this.envelopes.some(envelopeActive)
+    return this.enabled && (this.active || this.breathing || this.envelopes.some(envelopeActive))
   }
 
   get running() {

+ 24 - 0
packages/tui/test/component/tab-pulse.test.tsx

@@ -1,6 +1,10 @@
 import { expect, test } from "bun:test"
+/** @jsxImportSource @opentui/solid */
 import { RGBA } from "@opentui/core"
+import { testRender } from "@opentui/solid"
+import { createSignal } from "solid-js"
 import {
+  TabPulse,
   blendTabPulseColor,
   completionPulseOpacity,
   glowIgnitionLevel,
@@ -9,6 +13,26 @@ import {
 } from "../../src/component/tab-pulse"
 import { tint } from "../../src/theme/color"
 
+test("a disabled pulse stays idle when it becomes active", async () => {
+  const background = RGBA.fromHex("#101010")
+  const [active, setActive] = createSignal(false)
+  const app = await testRender(
+    () => <TabPulse enabled={false} active={active()} color={background} backgroundColor={background} />,
+    { width: 8, height: 1 },
+  )
+
+  try {
+    await app.renderOnce()
+    expect(app.renderer.root.liveCount).toBe(0)
+
+    setActive(true)
+    await app.renderOnce()
+    expect(app.renderer.root.liveCount).toBe(0)
+  } finally {
+    app.renderer.destroy()
+  }
+})
+
 test("completion pulse rises quickly and fades over the remaining duration", () => {
   expect(completionPulseOpacity(0)).toBe(0)
   expect(completionPulseOpacity(0.06)).toBeCloseTo(0.5)