fix(chat): repair the message row layout and action buttons
Three defects reported from real-machine testing, all rooted in the same few conflicting CSS blocks, so they are fixed together — separating them would leave intermediate states that render worse than either end. The action buttons showed wrapped vertical text inside a 2rem box. styles.css already defined .message-action-label, a clip-rect screen-reader-only class clearly written for these buttons, but nothing in the tree ever used it: ChatPanel rendered a bare span. Wire the class up so the buttons are icon-only, and drop the border so they read as plain icons rather than pills. .chat-message-actions and its buttons were defined five times across the stylesheet, three of those styling them as bordered pills that the final block then partially overrode. Remove .chat-message-actions button from the three pill rule groups and the small-screen grid rule, leaving one definition next to .message-action-icon. .chat-runtime-actions and .chat-stop-button keep the pill treatment; they are different controls. The avatar rendered below its bubble instead of beside it. .chat-message-row used align-items: flex-end, and .chat-message-content is taller than the bubble because the action bar reserves a row, so the avatar was pinned to the bottom of that taller box. Align to the top. Removing visibility: hidden from the hidden action bar also closes F-40 (audit P2-24): visibility removed the buttons from the tab order, so :focus-within could never fire and a keyboard user could never reveal them. Opacity alone keeps them focusable. Verified against the real stylesheet in a browser: avatar and bubble tops differ by 0px, the button computes to 34x34 with 0px border, the label measures 1x1, and focusing a button takes the bar from opacity 0 to 1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
这个提交存在于:
父节点
178fba70ea
当前提交
fa48a21e65
共有 2 个文件被更改,包括 31 次插入 和 33 次删除
|
|
@ -819,7 +819,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
|
||||||
className="message-action-icon icon-copy"
|
className="message-action-icon icon-copy"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
<span>复制</span>
|
<span className="message-action-label">复制</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
@ -831,7 +831,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
|
||||||
className="message-action-icon icon-retry"
|
className="message-action-icon icon-retry"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
<span>重试</span>
|
<span className="message-action-label">重试</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
@ -843,7 +843,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
|
||||||
className="message-action-icon icon-read"
|
className="message-action-icon icon-read"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
<span>朗读</span>
|
<span className="message-action-label">朗读</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,11 @@ select:focus {
|
||||||
|
|
||||||
.chat-message-row {
|
.chat-message-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
/* Aligns the avatar with the top of the bubble. It used to be `flex-end`,
|
||||||
|
which pinned the avatar to the bottom of `.chat-message-content` — and that
|
||||||
|
box is taller than the bubble because the action bar reserves a row, so the
|
||||||
|
avatar rendered below the bubble instead of beside it. */
|
||||||
|
align-items: flex-start;
|
||||||
gap: 0.55rem;
|
gap: 0.55rem;
|
||||||
width: min(82%, 46rem);
|
width: min(82%, 46rem);
|
||||||
justify-self: start;
|
justify-self: start;
|
||||||
|
|
@ -2176,14 +2180,10 @@ body,
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-runtime-actions,
|
.chat-runtime-actions,
|
||||||
.chat-message-actions {
|
/* `.chat-message-actions button` is intentionally absent from these pill rules.
|
||||||
display: flex;
|
Message actions are borderless icon buttons; their single definition lives
|
||||||
flex-wrap: wrap;
|
further down next to `.message-action-icon`. */
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-runtime-actions button,
|
.chat-runtime-actions button,
|
||||||
.chat-message-actions button,
|
|
||||||
.chat-stop-button {
|
.chat-stop-button {
|
||||||
border: 1px solid var(--line, #c8d8ea);
|
border: 1px solid var(--line, #c8d8ea);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
|
|
@ -2195,7 +2195,6 @@ body,
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-runtime-actions button:hover,
|
.chat-runtime-actions button:hover,
|
||||||
.chat-message-actions button:hover,
|
|
||||||
.chat-stop-button:hover {
|
.chat-stop-button:hover {
|
||||||
background: var(--soft-accent, #eaf3ff);
|
background: var(--soft-accent, #eaf3ff);
|
||||||
color: var(--accent, #2f6fb2);
|
color: var(--accent, #2f6fb2);
|
||||||
|
|
@ -2266,10 +2265,6 @@ body,
|
||||||
color: var(--accent, #2f6fb2);
|
color: var(--accent, #2f6fb2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-message-actions {
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-stop-button {
|
.chat-stop-button {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
border-color: #d88d8d;
|
border-color: #d88d8d;
|
||||||
|
|
@ -2459,7 +2454,6 @@ textarea:focus-visible,
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-runtime-actions button,
|
.chat-runtime-actions button,
|
||||||
.chat-message-actions button,
|
|
||||||
.chat-stop-button {
|
.chat-stop-button {
|
||||||
min-height: 2rem;
|
min-height: 2rem;
|
||||||
border: 1px solid var(--ui-line);
|
border: 1px solid var(--ui-line);
|
||||||
|
|
@ -2469,7 +2463,6 @@ textarea:focus-visible,
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-runtime-actions button:hover,
|
.chat-runtime-actions button:hover,
|
||||||
.chat-message-actions button:hover,
|
|
||||||
.chat-stop-button:hover {
|
.chat-stop-button:hover {
|
||||||
border-color: var(--ui-line-strong);
|
border-color: var(--ui-line-strong);
|
||||||
color: var(--ui-ink);
|
color: var(--ui-ink);
|
||||||
|
|
@ -2659,7 +2652,6 @@ textarea:focus-visible,
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-runtime-actions button,
|
.chat-runtime-actions button,
|
||||||
.chat-message-actions button,
|
|
||||||
.chat-stop-button,
|
.chat-stop-button,
|
||||||
.voice-button,
|
.voice-button,
|
||||||
.file-picker,
|
.file-picker,
|
||||||
|
|
@ -2668,6 +2660,10 @@ textarea:focus-visible,
|
||||||
touch-action: manipulation;
|
touch-action: manipulation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-message-actions button {
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
|
||||||
.chat-runtime-actions button:disabled {
|
.chat-runtime-actions button:disabled {
|
||||||
border-color: var(--ui-line);
|
border-color: var(--ui-line);
|
||||||
color: var(--ui-subtle);
|
color: var(--ui-subtle);
|
||||||
|
|
@ -2738,17 +2734,11 @@ textarea:focus-visible,
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-runtime-actions button,
|
.chat-runtime-actions button,
|
||||||
.chat-message-actions button,
|
|
||||||
.chat-stop-button,
|
.chat-stop-button,
|
||||||
.voice-button,
|
.voice-button,
|
||||||
.file-picker {
|
.file-picker {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-message-actions {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
|
|
@ -3125,27 +3115,31 @@ button:disabled {
|
||||||
transform: translateY(-0.2rem);
|
transform: translateY(-0.2rem);
|
||||||
transition:
|
transition:
|
||||||
opacity 150ms ease,
|
opacity 150ms ease,
|
||||||
transform 150ms ease,
|
transform 150ms ease;
|
||||||
visibility 150ms ease;
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Deliberately no `visibility: hidden`. It removed the buttons from the tab
|
||||||
|
order, so `:focus-within` could never fire and a keyboard user could never
|
||||||
|
reveal them. Opacity alone keeps them focusable. */
|
||||||
.chat-message-row:hover .chat-message-actions,
|
.chat-message-row:hover .chat-message-actions,
|
||||||
.chat-message-row:focus-within .chat-message-actions {
|
.chat-message-row:focus-within .chat-message-actions {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
visibility: visible;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The single definition of a message action button: borderless, icon only.
|
||||||
|
The visible label is carried by `.message-action-label`, which is clipped for
|
||||||
|
screen readers, so the button must never be sized for text. */
|
||||||
.chat-message-actions button {
|
.chat-message-actions button {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 2rem;
|
width: 2rem;
|
||||||
|
height: 2rem;
|
||||||
min-height: 2rem;
|
min-height: 2rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 1px solid transparent;
|
border: 0;
|
||||||
border-radius: 0.55rem;
|
border-radius: 0.55rem;
|
||||||
color: var(--ui-subtle);
|
color: var(--ui-subtle);
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
@ -3154,11 +3148,15 @@ button:disabled {
|
||||||
|
|
||||||
.chat-message-actions button:hover:not(:disabled),
|
.chat-message-actions button:hover:not(:disabled),
|
||||||
.chat-message-actions button:focus-visible {
|
.chat-message-actions button:focus-visible {
|
||||||
border-color: var(--ui-line);
|
|
||||||
color: var(--ui-ink);
|
color: var(--ui-ink);
|
||||||
background: var(--ui-surface-soft);
|
background: var(--ui-surface-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-message-actions button:hover:not(:disabled) .message-action-icon,
|
||||||
|
.chat-message-actions button:focus-visible .message-action-icon {
|
||||||
|
color: var(--ui-ink);
|
||||||
|
}
|
||||||
|
|
||||||
.message-action-label {
|
.message-action-label {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
|
|
@ -3285,11 +3283,12 @@ button:disabled {
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-message-actions button {
|
.chat-message-actions button {
|
||||||
|
width: 2.1rem;
|
||||||
|
height: 2.1rem;
|
||||||
min-height: 2.1rem;
|
min-height: 2.1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Stable chat session pills and native-style window controls. */
|
/* Stable chat session pills and native-style window controls. */
|
||||||
.chat-session-list {
|
.chat-session-list {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
|
@ -3364,7 +3363,6 @@ button:disabled {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.message-attachment-image {
|
.message-attachment-image {
|
||||||
display: block;
|
display: block;
|
||||||
max-width: min(22rem, 100%);
|
max-width: min(22rem, 100%);
|
||||||
|
|
|
||||||
正在加载…
添加表格
在新工单中引用