Fix: Ask (Gemini) panel placement with Comments in Sidebar enabled - #4214
Open
Ishaan488 wants to merge 1 commit into
Open
Fix: Ask (Gemini) panel placement with Comments in Sidebar enabled#4214Ishaan488 wants to merge 1 commit into
Ishaan488 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4206
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
#panelscontainer (ytd-engagement-panel-section-list-renderer[target-id="PAyouchat"]). ThecommentsSidebar()feature'sinitialSetup()function moves#panelswholesale intoprimaryInner(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
placeAskPanel()helper that pins the Ask panel directly above#commentsinsidesecondary-inner, usinginsertBeforeso 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).isLayoutApplied()to also verify the Ask panel's position and ordering, so the existingMutationObserver(observeLayoutChanges) automatically re-corrects it if it drifts — e.g. if the panel is opened after the initial layout has already settled.restoreAskPanel()call in the narrow (<1000px) layout branch, since YouTube hides#secondaryentirely 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#panelscontainer so it opens inline below the video as YouTube intends.Testing