{"success":true,"name":"when-an-overlay-won-t-sit-on-top-hunt-the-ancestor-that-trap","description":"A dropdown, tooltip, or modal is clipped, buried, or stuck despite huge z-index","category":"ai-brimind","path":"ai-brimind/when-an-overlay-won-t-sit-on-top-hunt-the-ancestor-that-trap/SKILL.md","file":"SKILL.md","content":"---\nname: when-an-overlay-won-t-sit-on-top-hunt-the-ancestor-that-trap\ndescription: \"A dropdown, tooltip, or modal is clipped, buried, or stuck despite huge z-index\"\n---\n\n# When an Overlay Won't Sit on Top, Hunt the Ancestor That Traps It\n\n## When to use\nAn overlay element renders behind others, gets cut off at a container's edge, or a fixed element scrolls with the page — and raising z-index changes nothing.\n\n## Example request\nz-index 99999 still loses to a sidebar → the element competes inside its ancestor's stacking context, not globally; trapped layer. dropdown cut at the card's border → an ancestor has overflow hidden or scroll; clipping cage. position fixed scrolls with content → an ancestor's transform or filter re-anchored it; broken fixed. — each fought the symptom while an ancestor held the leash.\n\n## Instructions\nAct as a detective who investigates the family, not just the suspect: when an overlay misbehaves, the guilty party is almost always an ancestor. Learn the three cages. Stacking contexts: z-index only competes among siblings within the same context, and many innocent ancestor properties create one (transform, opacity below one, filter, position with z-index) — so a child's 99999 can never beat an element outside its parent's context; find which ancestor forms the context before touching numbers. Overflow clipping: any ancestor with overflow hidden, auto, or scroll cuts children at its box, no z-index involved. Broken anchoring: an ancestor with a transform or filter becomes the reference for fixed descendants, so 'fixed' elements travel with it. Diagnose by walking up the tree in devtools, toggling suspects until the cage reveals itself. Then choose the fix deliberately: remove or relocate the offending property when it's accidental, or — the structural cure — render the overlay outside the trapping hierarchy entirely, via the framework's portal mechanism or the platform's native top-layer elements (dialogs, popovers), which escape all three cages by design. Follow the project's z-index scale for whatever layers remain. Only proceed once you can name the exact ancestor and property that caused it — because without that, the next overlay hits the same invisible wall.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #784\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}