Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(widget): fix bug with altered href #246

Merged
merged 1 commit into from
Feb 29, 2024
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
2 changes: 1 addition & 1 deletion public/widget/GYJwhgtkA/2.12.1/planner-web.css

Large diffs are not rendered by default.

458 changes: 231 additions & 227 deletions public/widget/GYJwhgtkA/2.12.1/planner-web.mjs

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions public/widget/GYJwhgtkA/2.12.1/planner-web.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/widget/HYMw1kA/2.12.1/planner-web.css

Large diffs are not rendered by default.

462 changes: 233 additions & 229 deletions public/widget/HYMw1kA/2.12.1/planner-web.mjs

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions public/widget/HYMw1kA/2.12.1/planner-web.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/widget/IYFwRkA/2.12.1/planner-web.css

Large diffs are not rendered by default.

462 changes: 233 additions & 229 deletions public/widget/IYFwRkA/2.12.1/planner-web.mjs

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions public/widget/IYFwRkA/2.12.1/planner-web.umd.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/widget/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,13 @@ function createOutput({ URL_BASE }: SettingConstants, texts: Texts) {
href="/assistant"
class="${style.tabSelected}"
id="pw-assistant-tab"
data-mode="assistant"
>
${texts.assistant.link}
</a>
</li>
<li>
<a href="/departures" id="pw-departures-tab">
<a href="/departures" id="pw-departures-tab" data-mode="departures">
${texts.departure.link}
</a>
</li>
Expand All @@ -737,16 +738,14 @@ function tabBar() {
document
.querySelector<HTMLUListElement>('.js-tablist')
?.addEventListener('click', function (e) {
e.preventDefault();

const tab = (e.target as HTMLElement)?.closest('a');
if (!tab) return;

const href = tab.getAttribute('href');
if (!href) return;
const mode = tab.getAttribute('data-mode');
if (!mode) return;

// Handle query params by splitting on `?` after replacing the `/`.
const [mode] = href.replace('/', '').split('?');

e.preventDefault();
const tabpanel = document.querySelector('#pw-' + mode);
if (!tabpanel) return;

Expand Down
Loading