{"summary":"Per far evitare bordi e barre a un pannello flottante, prima si delimita lo spazio utile e poi lo si posiziona al suo interno: 4 regole (menu che si ribaltano e limitano l’altezza, dialoghi con testata e piede fissi, tooltip a 8 direzioni con isteresi, barre fisse) e una demo interattiva.","notes":"<p>Tooltip, menu, finestre di dialogo e altri pannelli flottanti hanno contenuti di lunghezza variabile, e nemmeno le dimensioni della finestra dell’app o del viewport del browser sono fisse: è un dettaglio che l’IA trascura molto facilmente quando genera un’interfaccia. Se un pannello sa aprirsi solo in una direzione fissa, appena il trigger si avvicina al bordo del viewport, si trova in fondo a una lunga lista o scorre sotto l’header fisso, il pannello viene tagliato dal viewport oppure copre azioni importanti. La strada sicura è delimitare prima lo «spazio utile» del pannello: il viewport rientrato di 16px su ogni lato e, per i pannelli non modali dentro la pagina, anche al netto dell’header fisso e delle barre fisse in basso. Inoltre, monta il pannello al livello più alto tramite un Portal, così nessun contenitore padre lo taglia, e ricalcola la sua posizione a ogni apertura, scorrimento, ridimensionamento della finestra e cambio delle sue stesse dimensioni.</p>\n        <h2>Se non entra si ribalta, se è troppo alto si limita</h2>\n        <p>Di norma il menu si apre 8px sotto il trigger. Se sotto lo spazio non basta e sopra ce n’è a sufficienza, deve ribaltarsi automaticamente e aprirsi verso l’alto; allo stesso modo un sottomenu a cascata che non entra a destra passa a sinistra, e anche il punto di partenza dell’animazione di apertura (transform-origin) si sposta sul lato più vicino al trigger. Se dopo il ribaltamento sborda ancora di lato, fallo scorrere lungo il bordo del viewport fino a riportarlo nella zona sicura; se l’altezza complessiva del menu supera ancora lo spazio disponibile su quel lato, limita l’altezza massima del contenitore a quello spazio, fai scorrere il contenuto all’interno e aggiungi una dissolvenza sul bordo tagliato per segnalare che sotto c’è altro. Inoltre, se con il menu aperto l’utente scorre la pagina con il cursore fuori dal menu, la sua attenzione è già tornata all’interfaccia principale: il menu deve chiudersi subito con una dissolvenza.</p>\n        <ul>\n        <li><strong>Dove usarlo:</strong> menu a discesa, menu contestuali, sottomenu a cascata, selettori (Select)</li>\n        <li><strong>Parametri:</strong> 16px dal bordo del viewport, 8px dal trigger; ribaltare, far scorrere, poi limitare l’altezza con scorrimento interno; dissolvenza immediata se la pagina scorre fuori dal menu</li>\n        </ul>\n        <h2>Testata e piede della finestra di dialogo sempre visibili</h2>\n        <p>Quando una finestra di dialogo con molto contenuto si limita a crescere fino all’altezza piena restando centrata, la riga del titolo e quella delle azioni in basso escono dal viewport: l’utente perde il contesto e non trova il pulsante di conferma. Limita l’altezza massima della finestra di dialogo all’altezza sicura del viewport, fissa la barra del titolo e la barra delle azioni in basso, fai scorrere solo l’area di contenuto tra le due e mostra un separatore di 1px quando il contenuto passa sotto il titolo. Se in un caso il contenuto è spesso abbondante, meglio usare un drawer al posto della finestra di dialogo: un drawer laterale su desktop e, su mobile, direttamente un drawer inferiore a tutta larghezza che si apre dal basso verso l’alto.</p>\n        <ul>\n        <li><strong>Dove usarlo:</strong> finestre di dialogo con liste lunghe, pannelli delle impostazioni, moduli in finestra di dialogo, accettazione dei termini</li>\n        <li><strong>Parametri:</strong> 16px sopra e sotto, righe del titolo e delle azioni fisse, separatore di 1px sotto il titolo dopo lo scorrimento; drawer laterale o, su mobile, a tutta larghezza se il contenuto è spesso lungo</li>\n        </ul>\n        <h2>Tooltip che cambiano lato, cursor tip con isteresi</h2>\n        <p>Quando un tooltip esce da un bordo del viewport, deve ribaltarsi sul lato opposto; se sborda solo di poco vicino a un lato, si può anche farlo scorrere lungo il bordo fino a riportarlo nello spazio utile, con la freccia che punta sempre al centro del trigger. Un tooltip con freccia può prevedere 8 posizioni (sopra, sotto, a sinistra, a destra e i quattro angoli) e scegliere la migliore in base allo spazio rimasto verso ciascun bordo. Nei grafici, il cursor tip che segue il puntatore si posiziona di default in basso a destra, lasciando il cursore completamente libero; vicino al bordo destro passa a sinistra del cursore, e al ritorno torna a destra solo quando il cursore è rientrato di altri 24px oltre il punto del cambio. Questa isteresi evita che il cursor tip salti avanti e indietro quando il cursore si ferma vicino al limite. Per capire quando usare tooltip, cursor tip o drawer, vedi <a href=\"/it/009-overlays/\">009 Come scegliere tra tooltip, popover, drawer e finestre di dialogo</a>.</p>\n        <ul>\n        <li><strong>Dove usarlo:</strong> tooltip di pulsanti a icona e avatar, cursor tip con le letture dei grafici, schede informative che seguono il cursore</li>\n        <li><strong>Parametri:</strong> 8 posizioni scelte dinamicamente per i tooltip con freccia, freccia centrata sul trigger dopo lo scorrimento; cursor tip che lascia libero il cursore, isteresi di 24px prima di tornare</li>\n        </ul>\n        <h2>Lontano dall’header fisso e dalle barre in basso</h2>\n        <p>Qualsiasi pannello non modale, soprattutto tooltip, menu a discesa e Toast, deve evitare i contenitori fissati in alto o in basso (barra di navigazione superiore, barra del player, barra delle schede, campo di input della chat): nel calcolare lo spazio utile, sottrai prima l’altezza occupata da queste barre fisse. Il Toast deve fermarsi sopra la barra inferiore, per non coprire i controlli di riproduzione né la navigazione principale; un pannello che non si chiude allo scorrimento deve nascondersi non appena il suo trigger scorre sotto l’header fisso, invece di restare sospeso sopra la barra di navigazione. La finestra di dialogo modale, invece, prende il controllo dell’intero schermo con il suo overlay scuro: può coprire le barre fisse in alto e in basso, e il suo spazio utile è l’intero viewport.</p>\n        <ul>\n        <li><strong>Dove usarlo:</strong> tooltip e menu a discesa vicino all’header fisso o alla barra inferiore, Toast sopra la barra del player, la barra delle schede o il campo di input</li>\n        <li><strong>Parametri:</strong> spazio utile al netto delle barre fisse in alto e in basso, Toast a 16px dalla barra inferiore, pannello nascosto quando l’header fisso copre il trigger</li>\n        </ul>\n        <h2>Passalo all’AI</h2>\n        <p>Copia il Prompt qui sotto in uno strumento di IA come Claude Code, Codex, Cursor o WorkBuddy: prima passerà in rassegna menu, popover, tooltip, Toast e finestre di dialogo già presenti nel progetto, individuerà dove vengono tagliati dai bordi o coperti dalle barre fisse e li riassumerà in una tabella; dopo la tua conferma, aggiungerà direttamente nei componenti ribaltamento, scorrimento, limite di altezza e la logica per evitare bordi e barre.</p>","prompt":"Check the overlay components my product already has (menus and dropdowns, popovers, tooltips, toasts and dialogs), find where each one breaks at the extremes (by an edge of the window, low on a long page, under a sticky header, above a fixed bottom bar, with long content), and fix the cause in the component, so every place that uses it gets the fix. Diagnose first, and change only what I approve. Work inside my code and components, and do not add a dependency without asking. Every value below is a default to start from.\n\n0. Diagnose\n- List each overlay component, where it is defined (my own, or a library: Floating UI, Radix, MUI, Ant Design), and how it is placed today: preferred side, offset, whether it flips, shifts or caps its height, what it measures against, whether it is rendered in a portal, and when it places itself again.\n- Find what stays fixed on screen (sticky headers, bottom bars) and any clipping or scrolling container between an overlay and the window.\n- Find the places where each one fails: the last rows of a long list, the right end of a header, inside a scrolling panel, a dialog with its longest content. Trace each failure to its cause in the component, not to the page it shows up on.\n\n1. The room\n- Every overlay stays inside the window less 16px on each side. In the page, also less the sticky header and any fixed bottom bar; modal layers cover the bars. Render overlays in a portal.\n- Place it again on open, on scroll, on resize and when its own size changes, not once only.\n\n2. Menus and dropdowns\n- 8px from the trigger. When the preferred side has no room, flip to the other side, then shift along it into the room.\n- When it is still too tall, cap it to the room and let it scroll inside.\n- When the page scrolls while the pointer is outside the menu, fade it out and close it.\n- With Floating UI: offset(8), flip, shift and size with padding 16, and autoUpdate.\n\n3. Dialogs\n- No taller than the window less 16px. The title bar and the button bar stay put; only the content between them scrolls, with a 1px line where it passes under them.\n- Where the content is often long, suggest a side drawer on desktop and a full-width bottom sheet on phones, and ask me before changing.\n\n4. Tooltips\n- By an edge, flip to the opposite side or shift along it; the arrow keeps pointing at the trigger.\n- With an arrow, choose among 8 placements (above, below, left, right and the four corners) by the room on each side.\n- A tooltip that follows the pointer sits clear of the cursor, moves to its other side by an edge, and comes back only once the pointer is 24px further in.\n\n5. Fixed bars\n- No overlay, tooltips above all, covers a sticky header or a bottom bar. Toasts sit 16px above the bottom bar. An overlay whose trigger scrolls under the header hides with it.\n\n6. Report and check\n- Before changing anything, give me one table, one row per component: | Component | Used in | Today | Cases that fail | Cause | Fix | Values |. Ask me which rows to change.\n- Afterwards, go back to every failing case and check that it opens whole, inside the room.","skill":"/skills/kubai-overlay-avoidance/SKILL.md","skillText":"# 浮层避让的定位规则\n\n《999 个小技巧，让你 Vibe 的产品更有质感》第 026 期 · @kubai087\n\n在用户的项目里按下面的要求改造。要求以用户的口吻写成：文中的 I、me、my 指用户；写着要先问的地方，先停下来问用户再继续。\n\n## 改造要求\n\nCheck the overlay components my product already has (menus and dropdowns, popovers, tooltips, toasts and dialogs), find where each one breaks at the extremes (by an edge of the window, low on a long page, under a sticky header, above a fixed bottom bar, with long content), and fix the cause in the component, so every place that uses it gets the fix. Diagnose first, and change only what I approve. Work inside my code and components, and do not add a dependency without asking. Every value below is a default to start from.\n\n0. Diagnose\n- List each overlay component, where it is defined (my own, or a library: Floating UI, Radix, MUI, Ant Design), and how it is placed today: preferred side, offset, whether it flips, shifts or caps its height, what it measures against, whether it is rendered in a portal, and when it places itself again.\n- Find what stays fixed on screen (sticky headers, bottom bars) and any clipping or scrolling container between an overlay and the window.\n- Find the places where each one fails: the last rows of a long list, the right end of a header, inside a scrolling panel, a dialog with its longest content. Trace each failure to its cause in the component, not to the page it shows up on.\n\n1. The room\n- Every overlay stays inside the window less 16px on each side. In the page, also less the sticky header and any fixed bottom bar; modal layers cover the bars. Render overlays in a portal.\n- Place it again on open, on scroll, on resize and when its own size changes, not once only.\n\n2. Menus and dropdowns\n- 8px from the trigger. When the preferred side has no room, flip to the other side, then shift along it into the room.\n- When it is still too tall, cap it to the room and let it scroll inside.\n- When the page scrolls while the pointer is outside the menu, fade it out and close it.\n- With Floating UI: offset(8), flip, shift and size with padding 16, and autoUpdate.\n\n3. Dialogs\n- No taller than the window less 16px. The title bar and the button bar stay put; only the content between them scrolls, with a 1px line where it passes under them.\n- Where the content is often long, suggest a side drawer on desktop and a full-width bottom sheet on phones, and ask me before changing.\n\n4. Tooltips\n- By an edge, flip to the opposite side or shift along it; the arrow keeps pointing at the trigger.\n- With an arrow, choose among 8 placements (above, below, left, right and the four corners) by the room on each side.\n- A tooltip that follows the pointer sits clear of the cursor, moves to its other side by an edge, and comes back only once the pointer is 24px further in.\n\n5. Fixed bars\n- No overlay, tooltips above all, covers a sticky header or a bottom bar. Toasts sit 16px above the bottom bar. An overlay whose trigger scrolls under the header hides with it.\n\n6. Report and check\n- Before changing anything, give me one table, one row per component: | Component | Used in | Today | Cases that fail | Cause | Fix | Values |. Ask me which rows to change.\n- Afterwards, go back to every failing case and check that it opens whole, inside the room.\n"}