Revert "ui: fix accessibility for hover-gated interactive elements assisted by claude(in debugging and tests) (#24727)" (#25098)

This commit is contained in:
Aleksander Grygier
2026-06-28 21:30:03 +02:00
committed by GitHub
parent 7cb8576e7c
commit dbdaece23d
3 changed files with 83 additions and 58 deletions
@@ -33,7 +33,7 @@
{#if !readonly && onRemove} {#if !readonly && onRemove}
<div <div
class="absolute top-10 right-2 flex items-center justify-center opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100" class="absolute top-10 right-2 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100"
> >
<ActionIcon icon={X} tooltip="Remove" stopPropagationOnClick onclick={() => onRemove?.()} /> <ActionIcon icon={X} tooltip="Remove" stopPropagationOnClick onclick={() => onRemove?.()} />
</div> </div>
@@ -56,7 +56,7 @@
<div class="relative flex h-6 items-center justify-between"> <div class="relative flex h-6 items-center justify-between">
<div class="right-0 flex items-center gap-2 opacity-100 transition-opacity"> <div class="right-0 flex items-center gap-2 opacity-100 transition-opacity">
<div <div
class="pointer-events-auto inset-0 flex items-center gap-1 opacity-0 transition-all duration-150 group-focus-within:opacity-100 group-hover:opacity-100" class="pointer-events-auto inset-0 flex items-center gap-1 opacity-0 transition-all duration-150 group-hover:opacity-100"
> >
<ActionIcon icon={Edit} tooltip="Edit" onclick={editCtx.handleEdit} /> <ActionIcon icon={Edit} tooltip="Edit" onclick={editCtx.handleEdit} />
<ActionIcon icon={Trash2} tooltip="Delete" onclick={onDelete} /> <ActionIcon icon={Trash2} tooltip="Delete" onclick={onDelete} />
@@ -39,6 +39,7 @@
depth = 0 depth = 0
}: Props = $props(); }: Props = $props();
let renderActionsDropdown = $state(false);
let dropdownOpen = $state(false); let dropdownOpen = $state(false);
let isLoading = $derived(getAllLoadingChats().includes(conversation.id)); let isLoading = $derived(getAllLoadingChats().includes(conversation.id));
@@ -70,10 +71,26 @@
} }
} }
function handleMouseLeave() {
if (!dropdownOpen) {
renderActionsDropdown = false;
}
}
function handleMouseOver() {
renderActionsDropdown = true;
}
function handleSelect() { function handleSelect() {
onSelect?.(conversation.id); onSelect?.(conversation.id);
} }
$effect(() => {
if (!dropdownOpen) {
renderActionsDropdown = false;
}
});
onMount(() => { onMount(() => {
document.addEventListener('edit-active-conversation', handleGlobalEditEvent as EventListener); document.addEventListener('edit-active-conversation', handleGlobalEditEvent as EventListener);
@@ -86,19 +103,23 @@
}); });
</script> </script>
<div <!-- svelte-ignore a11y_mouse_events_have_key_events -->
class="conversation-item group relative flex min-h-9 w-full items-center justify-between space-x-3 rounded-lg py-1.5 transition-colors hover:bg-foreground/10 {isActive <button
class="group flex min-h-9 w-full cursor-pointer items-center justify-between space-x-3 rounded-lg py-1.5 text-left transition-colors hover:bg-foreground/10 {isActive
? 'bg-foreground/5 text-accent-foreground' ? 'bg-foreground/5 text-accent-foreground'
: ''} px-3" : ''} px-3"
>
<button
class="absolute inset-0 z-0 cursor-pointer rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"
onclick={handleSelect} onclick={handleSelect}
aria-label={conversation.name} onmouseover={handleMouseOver}
> onmouseleave={handleMouseLeave}
</button> onfocusin={handleMouseOver}
onfocusout={(e) => {
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) {
handleMouseLeave();
}
}}
>
<div <div
class="pointer-events-none relative z-10 flex min-w-0 flex-1 items-center gap-2" class="flex min-w-0 flex-1 items-center gap-2"
style:padding-left="{depth * FORK_TREE_DEPTH_PADDING}px" style:padding-left="{depth * FORK_TREE_DEPTH_PADDING}px"
> >
{#if depth > 0} {#if depth > 0}
@@ -109,7 +130,7 @@
<a <a
{...props} {...props}
href={RouterService.chat(conversation.forkedFromConversationId)} href={RouterService.chat(conversation.forkedFromConversationId)}
class="pointer-events-auto flex shrink-0 items-center text-muted-foreground transition-colors hover:text-foreground" class="flex shrink-0 items-center text-muted-foreground transition-colors hover:text-foreground"
> >
<GitBranch class="h-3.5 w-3.5" /> <GitBranch class="h-3.5 w-3.5" />
</a> </a>
@@ -125,15 +146,18 @@
{#if isLoading} {#if isLoading}
<Tooltip.Root> <Tooltip.Root>
<Tooltip.Trigger> <Tooltip.Trigger>
<button <div
class="stop-button pointer-events-auto flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground" class="stop-button flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground"
onclick={handleStop} onclick={handleStop}
onkeydown={(e) => e.key === 'Enter' && handleStop(e)}
role="button"
tabindex="0"
aria-label="Stop generation" aria-label="Stop generation"
> >
<Loader2 class="loading-icon h-3.5 w-3.5 animate-spin" /> <Loader2 class="loading-icon h-3.5 w-3.5 animate-spin" />
<Square class="stop-icon hidden h-3 w-3 fill-current text-destructive" /> <Square class="stop-icon hidden h-3 w-3 fill-current text-destructive" />
</button> </div>
</Tooltip.Trigger> </Tooltip.Trigger>
<Tooltip.Content> <Tooltip.Content>
@@ -145,7 +169,8 @@
<TruncatedText text={conversation.name} class="text-sm font-medium" showTooltip={false} /> <TruncatedText text={conversation.name} class="text-sm font-medium" showTooltip={false} />
</div> </div>
<div class="actions pointer-events-auto relative z-20 flex items-center"> {#if renderActionsDropdown}
<div class="actions flex items-center">
<DropdownMenuActions <DropdownMenuActions
triggerIcon={MoreHorizontal} triggerIcon={MoreHorizontal}
triggerTooltip="More actions" triggerTooltip="More actions"
@@ -185,10 +210,11 @@
]} ]}
/> />
</div> </div>
</div> {/if}
</button>
<style> <style>
.conversation-item { button {
:global([data-slot='dropdown-menu-trigger']:not([data-state='open'])) { :global([data-slot='dropdown-menu-trigger']:not([data-state='open'])) {
opacity: 0; opacity: 0;
} }
@@ -213,8 +239,7 @@
} }
} }
&:is(:hover) .stop-button, &:is(:hover) .stop-button {
&:focus-within .stop-button {
:global(.stop-icon) { :global(.stop-icon) {
display: block; display: block;
} }