mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-21 15:33:45 +00:00
🖱️ fix: Reveal Message Metadata on Hover, Not on Click (#14900)
* fix: reveal message metadata on hover, not on click
The message timestamp, the provider/model label crossfade, and the hover
action toolbar all revealed on `:focus-within` over the message row. A mouse
click sets focus, so clicking a tool card, an expand toggle, or a code block
button parked focus inside the row and pinned all three open long after the
pointer had left.
Key the focus half of each reveal on `:focus-visible` instead. A pointer
click no longer counts, while keyboard focus still does, so a sighted
keyboard user still reaches the model name and the timestamp by tabbing. An
action that opens a surface keeps the toolbar up through `hover-button-active`
as before.
* fix: fade the message row reveal instead of snapping it
The footer actions carried no opacity transition at all, so they arrived in a
single frame while the timestamp eased in behind them over 200ms and the
provider/model crossfade ran on the 300ms card-resize spring it had borrowed.
One hover, three different arrivals.
Put all three on the shared `duration-theme-normal` motion role with a common
ease-out, and add the reduced-motion guard the timestamp and the footer were
missing. `MinimalHoverButtons` now composes the shared reveal helper rather
than repeating its classes inline.
The reveal transition names `color` and `background-color` alongside `opacity`
because `cn` merges the whole `transition-*` group: a bare `transition-opacity`
would replace the `transition-colors` a `Button` contributes and the hover tint
would snap.
* fix: widen the message row keyboard-focus test
Two gaps in the `:focus-visible` reveal, both raised in review.
`:has()` never matches its own subject, so keying the reveal on
`:has(:focus-visible)` missed the row element itself. `MessageNav` moves the
reader by setting `tabindex="-1"` on the row and focusing it, which left a
focused row showing its focus ring while its timestamp, its model name and its
actions all stayed hidden.
Text-entry controls match `:focus-visible` even when a mouse clicks them, so a
click into the textareas `ToolApproval` and `AskUserQuestion` render inside a
row still pinned that row's metadata open with the pointer somewhere else. They
are excluded from the descendant half of the test. Every toolbar action is a
button, so a keyboard user still never focuses a hidden one.
Both halves are now one condition,
`:is(:focus-visible, :has(:focus-visible:not(:is(input, textarea, [contenteditable]))))`,
applied to the timestamp, the header label and the footer actions alike.
* fix: split the row focus test into two variants
Folding the row-itself and descendant halves into a single
`group-[&:is(...)]` made Tailwind emit a bare `.group$ { opacity: 1 }`, which
lightningcss refuses to minify. That failed the client CSS build and every job
downstream of it while jest and tsc stayed green, because neither ever builds
the stylesheet.
The condition is unchanged in behaviour, expressed as `group-focus-visible`
plus `group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]`.
The plain CSS in style.css keeps the `:is()` form, which is valid there.
The stale string also had to come out of the specs: tailwind scans
`src/**/*.{ts,tsx}`, so a class literal in a test file reaches the production
stylesheet.
* fix: split the timestamp focus selector too
`:has()` nested inside `:is()` made postcss log "Failed to parse selector" on
every client build. The rule survived intact, but the warning was noise coming
from this change, and splitting it matches how the Tailwind side now expresses
the same condition.
Behaviour is unchanged: hover, a focused row and a mouse-clicked textarea all
measure the same as before.
This commit is contained in:
parent
7d850c308a
commit
df5abbb377
8 changed files with 156 additions and 19 deletions
|
|
@ -582,14 +582,27 @@ pre {
|
|||
}
|
||||
|
||||
/* Show the message time when the row is hovered. Tailwind group-hover
|
||||
loses to `[@media(hover:hover)]:opacity-0` (same specificity, :where()). */
|
||||
loses to `[@media(hover:hover)]:opacity-0` (same specificity, :where()).
|
||||
|
||||
Keyboard focus reveals it too, but only `:focus-visible`: a pointer that
|
||||
clicks a tool card or an expand toggle inside the row leaves focus sitting
|
||||
there, and plain `:focus-within` would pin the time open long after the
|
||||
pointer moved away.
|
||||
|
||||
The condition matches the row itself as well as its descendants, because
|
||||
`MessageNav` focuses the row through `tabindex="-1"` and `:has()` never
|
||||
matches its own subject. Text-entry controls are excluded, because they
|
||||
match `:focus-visible` on a plain mouse click. See `revealOnRowHoverClasses`
|
||||
in `components/Chat/Messages/styles.ts` for the full reasoning. */
|
||||
@media (hover: hover) {
|
||||
.message-render .message-timestamp {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.message-render:hover .message-timestamp,
|
||||
.message-render:focus-within .message-timestamp {
|
||||
.message-render:focus-visible .message-timestamp,
|
||||
.message-render:has(:focus-visible:not(:is(input, textarea, [contenteditable])))
|
||||
.message-timestamp {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue