Skip to content

Fix: Ask (Gemini) panel placement with Comments in Sidebar enabled - #4214

Open
Ishaan488 wants to merge 1 commit into
code-charity:masterfrom
Ishaan488:master
Open

Fix: Ask (Gemini) panel placement with Comments in Sidebar enabled#4214
Ishaan488 wants to merge 1 commit into
code-charity:masterfrom
Ishaan488:master

Conversation

@Ishaan488

Copy link
Copy Markdown

Closes #4206

Before After
screenshot-1784388001754 screenshot-1784388175289

screenshot-1784388199585

Problem

When the "Comments in Sidebar" setting is enabled, the Ask (Gemini AI) panel gets displaced below the video description instead of staying in the sidebar above the comments section.

Root cause

The Ask panel renders inside YouTube's native #panels container (ytd-engagement-panel-section-list-renderer[target-id="PAyouchat"]). The commentsSidebar() feature's initialSetup() function moves #panels wholesale into primaryInner (the main content column) to handle live-chat panels — but this also carries the Ask panel along with it, stranding it in the main column instead of the sidebar.

Fix

  • Added a placeAskPanel() helper that pins the Ask panel directly above #comments inside secondary-inner, using insertBefore so the ordering is correct regardless of when the panel is rendered relative to other layout moves (this was inconsistent before — sometimes it landed above comments, sometimes below, depending on timing).
  • Updated isLayoutApplied() to also verify the Ask panel's position and ordering, so the existing MutationObserver (observeLayoutChanges) automatically re-corrects it if it drifts — e.g. if the panel is opened after the initial layout has already settled.
  • Added a restoreAskPanel() call in the narrow (<1000px) layout branch, since YouTube hides #secondary entirely at that width. Without this, the Ask panel would get stuck inside a hidden ancestor and appear to not open at all. It's now moved back into its native #panels container so it opens inline below the video as YouTube intends.

Testing

  • Verified on multiple videos at all three breakpoints (<1000px, 1000–1952px, >1952px)
  • Verified opening the Ask panel both before and after the sidebar layout settles
  • Verified toggling fullscreen/theater mode doesn't break placement
  • Verified narrow → wide → narrow cycling doesn't orphan or duplicate the panel
  • Verified the panel opens correctly natively when width is <1000px

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞Ask (Gemini AI) panel placed below the description when the comment placed in sidebar instead in sidebar too above the comment section

1 participant