Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(login): 修复返回钮/方式行悬停叠层盖住内容、输入框悬停叠层从未生效 (#5601)

DuoDuo52ed7876c2ee
diff --git a/apps/desktop/src/renderer/components/login/LoginControls.tsx b/apps/desktop/src/renderer/components/login/LoginControls.tsx
index 434488a9c8..176f5a224b 100644
--- a/apps/desktop/src/renderer/components/login/LoginControls.tsx
+++ b/apps/desktop/src/renderer/components/login/LoginControls.tsx
@@ -305,7 +305,9 @@ export function LoginInput({
width: CONTROL.width,
height: CONTROL.height,
borderRadius: CONTROL.radius,
- background: LOGIN_COLORS.controlBg,
+ // backgroundColor 而非 background 简写:简写会把 background-image 重置为 none,
+ // 上面 hover:enabled 的 5% 叠层(background-image)因此从未生效。
+ backgroundColor: LOGIN_COLORS.controlBg,
border: `1px solid ${
error
? LOGIN_COLORS.errorFg
@@ -649,8 +651,9 @@ export function LoginBackButton({
border: `1px solid ${LOGIN_COLORS.backBorder}`,
}}
>
- {/* 24 box 内左向 chevron(247:1635 icon 语义;矢量重绘,静态) */}
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden>
+ {/* 24 box 内左向 chevron(247:1635 icon 语义;矢量重绘,静态)。z-[1]:hover/pressed
+ 叠层(::after,亮色白 70%)只染底色,不盖住箭头——否则悬停时箭头仅 1.76:1。 */}
+ <svg className="relative z-[1]" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden>
<path
d="M14.5 5.5 8 12l6.5 6.5"
stroke={LOGIN_COLORS.controlText}
@@ -1251,7 +1254,7 @@ export function LoginMethodRow({
>
<span
aria-hidden
- className="absolute inline-flex"
+ className="absolute z-[1] inline-flex"
style={
!showLogo && icon === 'person'
? {
@@ -1283,7 +1286,7 @@ export function LoginMethodRow({
)}
</span>
<span
- className="absolute flex flex-col justify-center text-left"
+ className="absolute z-[1] flex flex-col justify-center text-left"
style={{
left: METHOD_ROW.textX,
top: 0,
@@ -1306,7 +1309,7 @@ export function LoginMethodRow({
</span>
<span
aria-hidden
- className="absolute inline-flex"
+ className="absolute z-[1] inline-flex"
style={{
left: METHOD_ROW.rightIcon.x,
top: METHOD_ROW.rightIcon.y,
diff --git a/apps/desktop/src/renderer/components/login/__tests__/LoginControls.hoverOverlay.test.tsx b/apps/desktop/src/renderer/components/login/__tests__/LoginControls.hoverOverlay.test.tsx
new file mode 100644
index 0000000000..5c7d321dde
--- /dev/null
+++ b/apps/desktop/src/renderer/components/login/__tests__/LoginControls.hoverOverlay.test.tsx
@@ -0,0 +1,49 @@
+// @vitest-environment jsdom
+
+import { cleanup, render, screen } from '@testing-library/react';
+import { afterEach, describe, expect, it } from 'vitest';
+
+import { LoginBackButton, LoginInput, LoginMethodRow } from '../LoginControls';
+
+/**
+ * hover / pressed 叠层只能染控件底色,不能盖住内容,也不能被内联样式吞掉:
+ * - 返回钮、方式行的叠层挂在 ::after 上(position:absolute,绘制在后),
+ * 内容层若没有 z-index 就会被盖住——亮色返回钮悬停时箭头只剩 1.76:1;
+ * - 输入框的 hover 叠层是 background-image,内联 `background` 简写会把它重置为
+ * none,导致悬停反馈从未生效。
+ */
+describe('登录控件 hover 叠层', () => {
+ afterEach(() => cleanup());
+
+ it('返回钮箭头位于叠层之上', () => {
+ render(<LoginBackButton label="Back" onClick={() => {}} />);
+ const svg = screen.getByTestId('login-back-button').querySelector('svg');
+ expect(svg?.getAttribute('class')).toContain('z-[1]');
+ });
+
+ it('方式行图标与文字位于叠层之上', () => {
+ render(
+ <LoginMethodRow
+ top={158}
+ title="Sign in with a personal account"
+ subtitle="Send a verification code to your email"
+ onClick={() => {}}
+ testId="row"
+ />,
+ );
+ const contentLayers = [...screen.getByTestId('row').children].filter((child) =>
+ child.className.includes('absolute'),
+ );
+ expect(contentLayers).toHaveLength(3);
+ for (const layer of contentLayers) expect(layer.className).toContain('z-[1]');
+ });
+
+ it('输入框底色不用 background 简写,hover 的 background-image 叠层得以生效', () => {
+ render(<LoginInput value="" onChange={() => {}} placeholder="Email" testId="input" />);
+ const input = screen.getByRole('textbox');
+ const style = input.getAttribute('style') ?? '';
+ expect(style).toContain('background-color');
+ expect(style).not.toMatch(/(^|;)\s*background:/);
+ expect(input.className).toContain('hover:enabled:[background-image:');
+ });
+});