Skip to content

Commit c1ce10c

Browse files
committed
fix(timeline): open location links outside the app
Fixes #1893 Signed-off-by: 7w1 <noreply@sl.sable.moe>
1 parent 6576a3f commit c1ce10c

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎.changeset/location-map-app.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fix location links freezing the app on Android.

‎src/lib/features/room/timeline/TimelineLocation.svelte‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@
5454
</script>
5555

5656
<div class="location">
57-
<a class="summary" {href} rel="external" aria-disabled={!valid || undefined}>
57+
<a
58+
class="summary"
59+
{href}
60+
target="_blank"
61+
rel="external noopener noreferrer"
62+
aria-disabled={!valid || undefined}
63+
>
5864
<MapPinIcon class="pin" size={20} aria-hidden="true" />
5965
<span class="text">
6066
<span class="label">{label}</span>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @vitest-environment happy-dom
2+
3+
import { render, screen } from '@testing-library/svelte';
4+
import { afterEach, expect, test } from 'vitest';
5+
6+
import { externalLinkRequest } from '#lib/platform/external-link-request.svelte.js';
7+
import { followExternalLink } from '#lib/platform/external-links.js';
8+
9+
import TimelineLocation from './TimelineLocation.svelte';
10+
11+
afterEach(() => {
12+
externalLinkRequest.current = null;
13+
});
14+
15+
test('location coordinates ask to open a map app without navigating the webview', () => {
16+
render(TimelineLocation, { body: 'Here', latitude: 48.8, longitude: 2.3 });
17+
const link = screen.getByRole<HTMLAnchorElement>('link', { name: /Here/ });
18+
const click = new MouseEvent('click', { bubbles: true, cancelable: true });
19+
20+
followExternalLink(click, link);
21+
22+
expect(click.defaultPrevented).toBe(true);
23+
expect(externalLinkRequest.current).toBe('geo:48.8,2.3');
24+
});

0 commit comments

Comments
 (0)