Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/list/ContentList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2228,14 +2228,17 @@ export class ContentList<T = any> extends RapidElement {
if (path.some((n: any) => n?.classList?.contains?.('check-cell'))) {
return;
}
const rowHref = this.getRowHref(item);
const href = rowHref && this.isSafeHref(rowHref) ? rowHref : null;
// Meta/ctrl-click opens a new tab, matching ordinary links. Skip
// RowClick entirely — host pages navigate on it unconditionally,
// which would also swap out the current page.
if (href && (event.metaKey || event.ctrlKey)) {
window.open(href, '_blank');
return;
}
this.fireCustomEvent(CustomEventType.RowClick, { item });
const href = this.getRowHref(item);
if (href && this.isSafeHref(href)) {
// Meta/ctrl-click opens a new tab, matching ordinary links.
if (event.metaKey || event.ctrlKey) {
window.open(href, '_blank');
return;
}
if (href) {
// Fire Redirected rather than assigning window.location so the
// host SPA frame swaps content in place instead of doing a full
// page reload — the frame listens for this event on document and
Expand Down
10 changes: 9 additions & 1 deletion test/temba-content-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ describe('temba-content-list', () => {
expect(redirectUrl).to.equal('/contact/read/u-1/');
});

it('opens a new tab on meta-click without firing temba-redirected', async () => {
it('opens a new tab on meta-click without firing temba-redirected or temba-row-click', async () => {
const list = (await getList({
endpoint: '/test-assets/content-list/items.json'
})) as ContentList;
Expand All @@ -340,6 +340,13 @@ describe('temba-content-list', () => {
redirected = true;
});

// Host pages navigate on RowClick unconditionally, so firing it on
// a meta-click would swap out the current page alongside the new tab.
let rowClicked = false;
list.addEventListener(CustomEventType.RowClick, () => {
rowClicked = true;
});

const openStub = stub(window, 'open');
try {
const row = list.shadowRoot!.querySelector(
Expand All @@ -355,6 +362,7 @@ describe('temba-content-list', () => {
expect(openStub.calledOnceWithExactly('/contact/read/u-1/', '_blank')).to
.be.true;
expect(redirected).to.be.false;
expect(rowClicked).to.be.false;
} finally {
openStub.restore();
}
Expand Down
Loading