Skip to content

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

Merged
dev-rb merged 2 commits into
mainfrom
rahul/fix-channel-media-viewer-navigation-arrows-showing-for-single-image
Apr 23, 2026
Merged

fix(channel): media viewer showing navigation for single item#2825
dev-rb merged 2 commits into
mainfrom
rahul/fix-channel-media-viewer-navigation-arrows-showing-for-single-image

Conversation

@dev-rb
Copy link
Copy Markdown
Contributor

@dev-rb dev-rb commented Apr 23, 2026

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@dev-rb has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 34 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 34 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ced926af-60e9-479e-8bef-3cb46923db96

📥 Commits

Reviewing files that changed from the base of the PR and between fb13ed8 and 59a84ec.

📒 Files selected for processing (2)
  • js/app/packages/channel/Media/MediaViewerDialog.tsx
  • js/app/packages/core/component/Lightbox.tsx
📝 Walkthrough

Walkthrough

A navigationVisible prop is added to media viewer components to conditionally control the rendering of previous and next navigation buttons. MediaViewerDialog determines visibility based on whether multiple media items exist and passes this state to both VideoViewerContent and Lightbox.

Changes

Cohort / File(s) Summary
Navigation Visibility Control
js/app/packages/channel/Media/MediaViewerDialog.tsx, js/app/packages/core/component/Lightbox.tsx
Introduces optional navigationVisible prop to media viewer components. MediaViewerDialog sets visibility based on hasMultipleItems() for both video and lightbox viewers. Lightbox now conditionally renders navigation arrow buttons using Solid's <Show> directive instead of always rendering them.

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description explaining the issue being fixed (navigation controls appearing for single items) and how the solution addresses it (conditionally rendering navigation controls based on item count).
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'fix:' prefix, is under 72 characters (61 characters), and clearly describes the main fix: preventing navigation arrows from showing when there's only a single media item.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
js/app/packages/core/component/Lightbox.tsx (1)

269-342: 🛠️ Refactor suggestion | 🟠 Major

Dead navVisible helper — the opacity class is always opacity-100.

navVisible is hard-coded to () => true, so the ternaries on lines 317 and 333 (and 350 for the index label) always resolve to 'opacity-100', and the 'opacity-0 pointer-events-none' branch is unreachable. Now that rendering is gated by <Show when={props.navigationVisible !== false}>, this leftover fade logic is dead code and adds noise. Also, each arrow is wrapped in its own <Show> with the same condition — consolidating to a single <Show> makes the intent clearer.

♻️ Proposed cleanup
-  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-opacity duration-300 disabled:cursor-not-allowed disabled:opacity-50';
-
-  const navVisible = () => true;
+  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 disabled:cursor-not-allowed disabled:opacity-50';
@@
         {/* Nav arrows — desktop only */}
-        <Show when={!isMobile()}>
-          <Show when={props.navigationVisible !== false}>
-            <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>
-          </Show>
-
-          <Show when={props.navigationVisible !== false}>
-            <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>
+        <Show when={!isMobile() && props.navigationVisible !== false}>
+          <button
+            class={cn(navButtonClass, 'left-4')}
+            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')}
+            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>

Apply the analogous cleanup at lines 346–358 for the index indicator (drop navVisible() from the class).

As per coding guidelines: "Eliminate redundant code and abstractions" and "Reduce unnecessary complexity and nesting in code logic".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@js/app/packages/core/component/Lightbox.tsx` around lines 269 - 342,
navVisible() is dead code and the arrow opacity ternaries are unreachable;
remove the navVisible helper and simplify the markup by consolidating the two
separate <Show when={props.navigationVisible !== false}> wrappers into a single
<Show> that wraps both navigation buttons (and the index indicator), and update
the button/index class usage to drop the navVisible() ternaries (use
navButtonClass plus the static positioning and desired opacity classes, e.g.
'left-4 opacity-100' and 'right-4 opacity-100'); update references in the
Lightbox component (navVisible, navButtonClass, the buttons using
onPrevious/onNext, and the index label) accordingly so there’s no dead helper or
redundant <Show> nesting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@js/app/packages/channel/Media/MediaViewerDialog.tsx`:
- Around line 62-84: The two identical conditional wrappers using Show (Show
when={props.navigationVisible !== false}) should be merged into a single Show
that wraps both navigation buttons; locate the Show blocks around the left and
right nav buttons (the buttons using navButtonClass, ChevronLeftIcon and
ChevronRightIcon, stackingContext.zModal, onPrevious/onNext and disabled checks)
and move both buttons inside one Show with the same condition so behavior and
props (aria-label, onClick, disabled, style) remain unchanged.

---

Outside diff comments:
In `@js/app/packages/core/component/Lightbox.tsx`:
- Around line 269-342: navVisible() is dead code and the arrow opacity ternaries
are unreachable; remove the navVisible helper and simplify the markup by
consolidating the two separate <Show when={props.navigationVisible !== false}>
wrappers into a single <Show> that wraps both navigation buttons (and the index
indicator), and update the button/index class usage to drop the navVisible()
ternaries (use navButtonClass plus the static positioning and desired opacity
classes, e.g. 'left-4 opacity-100' and 'right-4 opacity-100'); update references
in the Lightbox component (navVisible, navButtonClass, the buttons using
onPrevious/onNext, and the index label) accordingly so there’s no dead helper or
redundant <Show> nesting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac218ec4-9256-46f6-abb9-64305c18eea5

📥 Commits

Reviewing files that changed from the base of the PR and between 6516ed4 and fb13ed8.

📒 Files selected for processing (2)
  • js/app/packages/channel/Media/MediaViewerDialog.tsx
  • js/app/packages/core/component/Lightbox.tsx

Comment on lines +62 to +84
<Show when={props.navigationVisible !== false}>
<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>

<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 when={props.navigationVisible !== false}>
<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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consolidate the two <Show> blocks with identical conditions.

Both nav buttons are wrapped in separate <Show when={props.navigationVisible !== false}> blocks with the same condition. Merging into a single <Show> reduces duplication and makes the intent clearer.

♻️ Proposed fix
-        <Show when={props.navigationVisible !== false}>
-          <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>
-
-        <Show when={props.navigationVisible !== false}>
-          <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>
+        <Show when={props.navigationVisible !== false}>
+          <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>
+        </Show>

As per coding guidelines: "Reduce unnecessary complexity and nesting in code logic".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Show when={props.navigationVisible !== false}>
<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>
<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 when={props.navigationVisible !== false}>
<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>
<Show when={props.navigationVisible !== false}>
<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>
</Show>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@js/app/packages/channel/Media/MediaViewerDialog.tsx` around lines 62 - 84,
The two identical conditional wrappers using Show (Show
when={props.navigationVisible !== false}) should be merged into a single Show
that wraps both navigation buttons; locate the Show blocks around the left and
right nav buttons (the buttons using navButtonClass, ChevronLeftIcon and
ChevronRightIcon, stackingContext.zModal, onPrevious/onNext and disabled checks)
and move both buttons inside one Show with the same condition so behavior and
props (aria-label, onClick, disabled, style) remain unchanged.

@dev-rb dev-rb merged commit 2654319 into main Apr 23, 2026
23 checks passed
@dev-rb dev-rb deleted the rahul/fix-channel-media-viewer-navigation-arrows-showing-for-single-image branch April 23, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant