Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(channel): media viewer showing navigation for single item (#2825)

dev-rb2654319916a4
diff --git a/js/app/packages/channel/Media/MediaViewerDialog.tsx b/js/app/packages/channel/Media/MediaViewerDialog.tsx
index d9973e1b21..3e2abab27d 100644
--- a/js/app/packages/channel/Media/MediaViewerDialog.tsx
+++ b/js/app/packages/channel/Media/MediaViewerDialog.tsx
@@ -22,6 +22,7 @@ function VideoViewerContent(props: {
onPrevious?: () => void;
onNext?: () => void;
indexLabel?: Accessor<string>;
+ navigationHidden?: boolean;
}) {
const navButtonClass =
'absolute top-1/2 -translate-y-1/2 bg-dialog backdrop-blur-sm rounded-lg border border-edge p-2 shadow-md hover:bg-button transition-colors disabled:cursor-not-allowed disabled:opacity-50';
@@ -58,25 +59,27 @@ function VideoViewerContent(props: {
</div>
</Show>
- <button
- class={cn(navButtonClass, 'left-4')}
- style={{ 'z-index': stackingContext.zModal + 1 }}
- onClick={props.onPrevious}
- disabled={!props.onPrevious}
- aria-label="Previous media"
- >
- <ChevronLeftIcon class="h-5 w-5 text-ink" />
- </button>
+ <Show when={!props.navigationHidden}>
+ <button
+ class={cn(navButtonClass, 'left-4')}
+ style={{ 'z-index': stackingContext.zModal + 1 }}
+ onClick={props.onPrevious}
+ disabled={!props.onPrevious}
+ aria-label="Previous media"
+ >
+ <ChevronLeftIcon class="h-5 w-5 text-ink" />
+ </button>
- <button
- class={cn(navButtonClass, 'right-4')}
- style={{ 'z-index': stackingContext.zModal + 1 }}
- onClick={props.onNext}
- disabled={!props.onNext}
- aria-label="Next media"
- >
- <ChevronRightIcon class="h-5 w-5 text-ink" />
- </button>
+ <button
+ class={cn(navButtonClass, 'right-4')}
+ style={{ 'z-index': stackingContext.zModal + 1 }}
+ onClick={props.onNext}
+ disabled={!props.onNext}
+ aria-label="Next media"
+ >
+ <ChevronRightIcon class="h-5 w-5 text-ink" />
+ </button>
+ </Show>
<div class="flex h-full w-full items-center justify-center">
<video
@@ -124,6 +127,7 @@ export function MediaViewerDialog(props: MediaViewerDialogProps) {
onPrevious={hasPrevious() ? navigatePrevious : undefined}
onNext={hasNext() ? navigateNext : undefined}
indexLabel={hasMultipleItems() ? indexLabel : undefined}
+ navigationHidden={!hasMultipleItems()}
/>
}
>
@@ -132,6 +136,7 @@ export function MediaViewerDialog(props: MediaViewerDialogProps) {
imageId={() => item().id}
onPrevious={hasPrevious() ? navigatePrevious : undefined}
onNext={hasNext() ? navigateNext : undefined}
+ navigationHidden={!hasMultipleItems()}
indexLabel={hasMultipleItems() ? indexLabel : undefined}
/>
</Show>
diff --git a/js/app/packages/core/component/Lightbox.tsx b/js/app/packages/core/component/Lightbox.tsx
index b0af16539c..5866837e2c 100644
--- a/js/app/packages/core/component/Lightbox.tsx
+++ b/js/app/packages/core/component/Lightbox.tsx
@@ -45,6 +45,7 @@ type LightboxProps = {
onNext?: () => void;
// "2/5" style indicator — rendered when provided
indexLabel?: Accessor<string>;
+ navigationHidden?: boolean;
};
export function Lightbox(props: LightboxProps) {
@@ -308,33 +309,35 @@ export function Lightbox(props: LightboxProps) {
{/* Nav arrows — desktop only */}
<Show when={!isMobile()}>
- <button
- class={cn(
- navButtonClass,
- 'left-4',
- navVisible() ? 'opacity-100' : 'opacity-0 pointer-events-none'
- )}
- style={{ 'z-index': stackingContext.zModal + 1 }}
- onClick={props.onPrevious}
- disabled={!props.onPrevious}
- aria-label="Previous image"
- >
- <ChevronLeftIcon class="w-5 h-5 text-ink" />
- </button>
-
- <button
- class={cn(
- navButtonClass,
- 'right-4',
- navVisible() ? 'opacity-100' : 'opacity-0 pointer-events-none'
- )}
- style={{ 'z-index': stackingContext.zModal + 1 }}
- onClick={props.onNext}
- disabled={!props.onNext}
- aria-label="Next image"
- >
- <ChevronRightIcon class="w-5 h-5 text-ink" />
- </button>
+ <Show when={!props.navigationHidden}>
+ <button
+ class={cn(
+ navButtonClass,
+ 'left-4',
+ navVisible() ? 'opacity-100' : 'opacity-0 pointer-events-none'
+ )}
+ style={{ 'z-index': stackingContext.zModal + 1 }}
+ onClick={props.onPrevious}
+ disabled={!props.onPrevious}
+ aria-label="Previous image"
+ >
+ <ChevronLeftIcon class="w-5 h-5 text-ink" />
+ </button>
+
+ <button
+ class={cn(
+ navButtonClass,
+ 'right-4',
+ navVisible() ? 'opacity-100' : 'opacity-0 pointer-events-none'
+ )}
+ style={{ 'z-index': stackingContext.zModal + 1 }}
+ onClick={props.onNext}
+ disabled={!props.onNext}
+ aria-label="Next image"
+ >
+ <ChevronRightIcon class="w-5 h-5 text-ink" />
+ </button>
+ </Show>
</Show>
{/* Index indicator */}