Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(self-learning): anchor the habit lesson preview below the row (#19419)

Arvin Xufaee5f676f0d
diff --git a/src/features/SelfLearning/Portrait/HabitList.tsx b/src/features/SelfLearning/Portrait/HabitList.tsx
index 6e7252dee9c..765c10e1dbe 100644
--- a/src/features/SelfLearning/Portrait/HabitList.tsx
+++ b/src/features/SelfLearning/Portrait/HabitList.tsx
@@ -163,11 +163,12 @@ const HabitRow = memo<HabitRowProps>(({ agentId, domainTitle, habit, onChanged,
<Popover
// Long enough that dragging the pointer down the list does not fetch every row.
openDelay={420}
- // Above the row rather than below it: the row's own hint sits directly beneath the
- // title, so a card there buries the line the reader just came from.
- placement={'topRight'}
- // This stack never flips a popup to the opposite side, so the card has to fit in the
- // space above the row; the padding keeps it clear of the viewport edge.
+ // Below the row by preference, so the row the reader is pointing at stays visible
+ // while they move into the card.
+ placement={'bottomRight'}
+ // Preference, not a rule: reading down a list parks the pointer on the last visible
+ // row, and pinning the card downward there pushes its body off-screen. Base UI's
+ // default side avoidance flips it back above when the space below runs out.
positionerProps={{ collisionPadding: 12 }}
trigger={'hover'}
content={
diff --git a/src/features/SelfLearning/Portrait/LessonPreview.tsx b/src/features/SelfLearning/Portrait/LessonPreview.tsx
index 66c175b50c7..7b097f9db79 100644
--- a/src/features/SelfLearning/Portrait/LessonPreview.tsx
+++ b/src/features/SelfLearning/Portrait/LessonPreview.tsx
@@ -26,9 +26,8 @@ const styles = createStaticStyles(({ css }) => ({
/* less the popup's own chrome, which sits outside this element */
/*
- * The card is anchored above the row, and this stack never flips a popup to the opposite
- * side — an explicit collisionAvoidance side:'flip' was measured to do nothing. So for a row
- * high on the page the card has to fit in the space above it or its tail becomes unreachable.
+ * The card prefers the space below the row but flips above when that runs out, so this
+ * tracks whichever side Base UI actually chose rather than assuming one of them.
*/
max-height: calc(var(--available-height, 100dvh) - 16px);
`,
@@ -64,7 +63,7 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
-/** Kept low so the card fits above the row it describes; the rest is one line away. */
+/** Kept low so the card fits beside the row it describes; the rest is one line away. */
const MAX_EVIDENCE = 2;
interface LessonPreviewProps {