SimpleChatTCRV:CMPopOver:Relative positioning - P1

Use position fixed followed by using position-area so that one
can use anchor passed through showPopover.

Avoid the hidePopover from mouseLeave, because as the mouse moves
over the poped up popover ui, the mouseLeave will be called on
the chat message block/container. And that would have closed the
popover and inturn mouseEnter would have got called on ChatMsg,
given now with the popover hidden, the ChatMsg block is directly
accessible. So this leads to twinkling / toggling ie continues
show/hide of the popover.

Inturn in mouseEnter itself decide when to close the previous
popover (ie if the chatmessage id is different from what it was
before).
This commit is contained in:
hanishkvc 2025-11-14 03:17:12 +05:30
parent 62fb992e0e
commit 70a163fd18
2 changed files with 11 additions and 7 deletions

View File

@ -93,7 +93,12 @@
max-height: 20vmin;
}
#popover-chatmsg {
position:absolute;
position:fixed;
position-area: span-bottom center;
/*
inset-block-end: anchor(end)-;
inset-inline-end: anchor(self-start);
*/
background-color: transparent;
padding: 0;
border-width: 0;

View File

@ -1211,17 +1211,16 @@ class MultiChatUI {
secMain.classList.add(`role-${msg.ns.role}`)
secMain.classList.add('chat-message')
secMain.addEventListener('mouseenter', (ev)=>{
let trect = secMain.getBoundingClientRect();
let prect = this.elPopoverChatMsg.getBoundingClientRect();
this.elPopoverChatMsg.style.top = `${trect.top+2}px`
this.elPopoverChatMsg.style.left = `${((trect.width)*0.9) - prect.width}px`
console.log(`DBUG:MCUI:ChatMessageMEnter:${msg.uniqId}`)
if (this.uniqIdChatMsgPO != msg.uniqId) {
this.elPopoverChatMsg.hidePopover()
}
this.uniqIdChatMsgPO = msg.uniqId
// @ts-ignore
this.elPopoverChatMsg.showPopover({source: secMain})
})
secMain.addEventListener('mouseleave', (ev)=>{
this.elPopoverChatMsg.hidePopover()
//this.uniqIdChatMsgPO = -1
console.log(`DBUG:MCUI:ChatMessageMLeave:${msg.uniqId}`)
})
elParent?.append(secMain)
this.elLastChatMessage = secMain;