Skip to content

Commit d00c05c

Browse files
fix(ui): use one sharing menu scroll
1 parent 58f7ac7 commit d00c05c

3 files changed

Lines changed: 41 additions & 42 deletions

File tree

‎ui/src/e2e/session-ownership.e2e.test.ts‎

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ suite.define(() => {
468468
expect(await gateway.getRequests("session.members.add")).toHaveLength(0);
469469
});
470470

471-
it("keeps high-volume member lists compact while visibility stays pinned", async () => {
471+
it("scrolls high-volume sharing through one compact menu", async () => {
472472
const context = await suite.browser.newContext({ viewport: { height: 800, width: 1280 } });
473473
const currentPage = await context.newPage();
474474
page = currentPage;
@@ -529,26 +529,53 @@ suite.define(() => {
529529

530530
const beforeScroll = await dropdown.evaluate((element) => {
531531
const menu = element.shadowRoot?.querySelector<HTMLElement>('[part="menu"]');
532-
const visibility = element.querySelector<HTMLElement>(".chat-pane__sharing-visibility-item");
532+
const visibilityTitle = element.querySelector<HTMLElement>(
533+
".chat-pane__sharing-visibility-title",
534+
);
535+
const visibilityItems = [
536+
...element.querySelectorAll<HTMLElement>(".chat-pane__sharing-visibility-item"),
537+
];
533538
const membersTitle = element.querySelector<HTMLElement>(".chat-pane__sharing-members-title");
534539
const firstMember = element.querySelector<HTMLElement>(".chat-pane__sharing-member");
540+
const previousVisibilityRect = visibilityItems.at(-2)?.getBoundingClientRect();
541+
const lastVisibilityRect = visibilityItems.at(-1)?.getBoundingClientRect();
542+
const membersTitleRect = membersTitle?.getBoundingClientRect();
535543
return {
536544
menuHeight: menu?.getBoundingClientRect().height ?? 0,
545+
menuTop: menu?.getBoundingClientRect().top ?? 0,
537546
scrollHeight: menu?.scrollHeight ?? 0,
538547
clientHeight: menu?.clientHeight ?? 0,
539-
visibilityTop: visibility?.getBoundingClientRect().top ?? 0,
540548
firstMemberTop: firstMember?.getBoundingClientRect().top ?? 0,
549+
groupGap:
550+
membersTitleRect && lastVisibilityRect
551+
? membersTitleRect.top - lastVisibilityRect.bottom
552+
: 0,
553+
rowGap:
554+
previousVisibilityRect && lastVisibilityRect
555+
? lastVisibilityRect.top - previousVisibilityRect.bottom
556+
: 0,
541557
membersTitleInset: Number.parseFloat(
542558
membersTitle ? getComputedStyle(membersTitle).paddingInlineStart : "0",
543559
),
544560
firstMemberInset: Number.parseFloat(
545561
firstMember ? getComputedStyle(firstMember).paddingInlineStart : "0",
546562
),
563+
visibilityTitlePosition: visibilityTitle ? getComputedStyle(visibilityTitle).position : "",
564+
membersTitlePosition: membersTitle ? getComputedStyle(membersTitle).position : "",
565+
nestedScrollers: [...element.children].filter((child) => {
566+
const node = child as HTMLElement;
567+
return (
568+
node.scrollHeight > node.clientHeight &&
569+
["auto", "scroll"].includes(getComputedStyle(node).overflowY)
570+
);
571+
}).length,
547572
};
548573
});
549574
const afterScroll = await dropdown.evaluate(async (element) => {
550575
const menu = element.shadowRoot?.querySelector<HTMLElement>('[part="menu"]');
551-
const visibility = element.querySelector<HTMLElement>(".chat-pane__sharing-visibility-item");
576+
const visibilityTitle = element.querySelector<HTMLElement>(
577+
".chat-pane__sharing-visibility-title",
578+
);
552579
const membersTitle = element.querySelector<HTMLElement>(".chat-pane__sharing-members-title");
553580
const firstMember = element.querySelector<HTMLElement>(".chat-pane__sharing-member");
554581
if (menu) {
@@ -559,7 +586,7 @@ suite.define(() => {
559586
});
560587
return {
561588
scrollTop: menu?.scrollTop ?? 0,
562-
visibilityTop: visibility?.getBoundingClientRect().top ?? 0,
589+
visibilityTitleBottom: visibilityTitle?.getBoundingClientRect().bottom ?? 0,
563590
membersTitleTop: membersTitle?.getBoundingClientRect().top ?? 0,
564591
firstMemberTop: firstMember?.getBoundingClientRect().top ?? 0,
565592
};
@@ -568,10 +595,14 @@ suite.define(() => {
568595
expect(beforeScroll.menuHeight).toBeLessThanOrEqual(421);
569596
expect(beforeScroll.scrollHeight).toBeGreaterThan(beforeScroll.clientHeight);
570597
expect(beforeScroll.membersTitleInset).toBe(beforeScroll.firstMemberInset);
598+
expect(beforeScroll.groupGap).toBeGreaterThanOrEqual(8);
599+
expect(beforeScroll.groupGap).toBeGreaterThan(beforeScroll.rowGap + 6);
600+
expect(beforeScroll.visibilityTitlePosition).not.toBe("sticky");
601+
expect(beforeScroll.membersTitlePosition).not.toBe("sticky");
602+
expect(beforeScroll.nestedScrollers).toBe(0);
571603
expect(afterScroll.scrollTop).toBeGreaterThan(0);
572-
expect(Math.abs(afterScroll.visibilityTop - beforeScroll.visibilityTop)).toBeLessThan(1);
573-
expect(afterScroll.membersTitleTop).toBeGreaterThan(afterScroll.visibilityTop);
574-
expect(afterScroll.membersTitleTop).toBeLessThan(beforeScroll.firstMemberTop);
604+
expect(afterScroll.visibilityTitleBottom).toBeLessThan(beforeScroll.menuTop);
605+
expect(afterScroll.membersTitleTop).toBeLessThan(beforeScroll.menuTop);
575606
expect(afterScroll.firstMemberTop).toBeLessThan(beforeScroll.firstMemberTop);
576607
await expectBrowser(
577608
dropdown.locator(".chat-pane__sharing-member openclaw-session-owner-chip"),

‎ui/src/pages/chat/components/chat-session-sharing.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export function renderChatSessionSharing(props: ChatSessionSharingProps) {
8181
return html`
8282
<wa-dropdown
8383
class="chat-pane__sharing-menu ${shouldCapMembers ? "chat-pane__sharing-menu--capped" : ""}"
84-
style=${`--sharing-visibility-count: ${visibilityOptions.length}`}
8584
placement="bottom-end"
8685
@wa-show=${() => {
8786
if (!props.openDisabledReason) {
@@ -137,10 +136,9 @@ export function renderChatSessionSharing(props: ChatSessionSharingProps) {
137136
${t("chat.sessionSharing.visibility")}
138137
</div>
139138
${visibilityOptions.map(
140-
(option, index) => html`
139+
(option) => html`
141140
<wa-dropdown-item
142141
class="session-menu__item chat-pane__sharing-visibility-item"
143-
style=${`--sharing-sticky-index: ${index}`}
144142
value=${`visibility:${option}`}
145143
?disabled=${option === visibility || Boolean(props.visibilityDisabledReason)}
146144
title=${props.visibilityDisabledReason ?? nothing}

‎ui/src/styles/chat/split-view.css‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ openclaw-chat-pane {
505505
}
506506

507507
.chat-pane__sharing-menu {
508-
--sharing-title-height: 28px;
509508
flex: 0 0 auto;
510509
}
511510

@@ -537,42 +536,13 @@ openclaw-chat-pane {
537536
padding: 6px 12px;
538537
}
539538

540-
.chat-pane__sharing-visibility-title,
541-
.chat-pane__sharing-visibility-item {
542-
position: sticky;
543-
z-index: 2;
544-
background: var(--bg-elevated);
545-
}
546-
547-
.chat-pane__sharing-visibility-title {
548-
top: 0;
549-
box-sizing: border-box;
550-
height: var(--sharing-title-height);
551-
}
552-
553-
.chat-pane__sharing-visibility-item {
554-
top: calc(var(--sharing-title-height) + var(--sharing-sticky-index) * var(--menu-item-height));
555-
}
556-
557-
.chat-pane__sharing-visibility-item:hover:not([disabled]),
558-
.chat-pane__sharing-visibility-item:focus-visible {
559-
background: var(--bg-hover);
560-
}
561-
562539
.chat-pane__sharing-visibility-item[disabled] {
563540
opacity: 1;
564541
color: var(--muted);
565542
}
566543

567544
.chat-pane__sharing-members-title {
568-
position: sticky;
569-
z-index: 2;
570-
top: calc(
571-
var(--sharing-title-height) + var(--sharing-visibility-count) * var(--menu-item-height)
572-
);
573-
box-sizing: border-box;
574-
height: var(--sharing-title-height);
575-
background: var(--bg-elevated);
545+
margin-top: 8px;
576546
}
577547

578548
.chat-pane__sharing-member {

0 commit comments

Comments
 (0)