fix(web): prevent thumbhashes from covering search bar (#20720)

The thumbhash had a z-index setting which meant it would cover the search bar,
and would always cause weird animations when scrolling up in search results.

This is fixable by removing the z-index and moving it in front the other
elements to get a naturally higher higher z-index preference.
This commit is contained in:
Thomas
2025-08-06 22:57:51 +01:00
committed by GitHub
parent f1c494ef97
commit f36efd128b
4 changed files with 25 additions and 57 deletions

View File

@@ -1,13 +1,10 @@
<script lang="ts">
import { thumbhash } from '$lib/actions/thumbhash';
import BrokenAsset from '$lib/components/assets/broken-asset.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import { cancelImageUrl } from '$lib/utils/sw-messaging';
import { TUNABLES } from '$lib/utils/tunables';
import { mdiEyeOffOutline } from '@mdi/js';
import type { ActionReturn } from 'svelte/action';
import type { ClassValue } from 'svelte/elements';
import { fade } from 'svelte/transition';
interface Props {
url: string;
@@ -15,7 +12,6 @@
title?: string | null;
heightStyle?: string | undefined;
widthStyle: string;
base64ThumbHash?: string | null;
curve?: boolean;
shadow?: boolean;
circle?: boolean;
@@ -33,7 +29,6 @@
title = null,
heightStyle = undefined,
widthStyle,
base64ThumbHash = null,
curve = false,
shadow = false,
circle = false,
@@ -45,10 +40,6 @@
brokenAssetClass = '',
}: Props = $props();
let {
IMAGE_THUMBNAIL: { THUMBHASH_FADE_DURATION },
} = TUNABLES;
let loaded = $state(false);
let errored = $state(false);
@@ -100,7 +91,6 @@
alt={loaded || errored ? altText : ''}
{title}
class={['object-cover', optionalClasses, imageClass]}
class:opacity-0={!thumbhash && !loaded}
draggable="false"
/>
{/if}
@@ -110,19 +100,3 @@
<Icon {title} path={mdiEyeOffOutline} size="2em" class={hiddenIconClass} />
</div>
{/if}
{#if base64ThumbHash && (!loaded || errored)}
<canvas
use:thumbhash={{ base64ThumbHash }}
data-testid="thumbhash"
style:width={widthStyle}
style:height={heightStyle}
{title}
class="absolute top-0 object-cover"
class:rounded-xl={curve}
class:shadow-lg={shadow}
class:rounded-full={circle}
draggable="false"
out:fade={{ duration: THUMBHASH_FADE_DURATION }}
></canvas>
{/if}