Skip to content

fix(notifications): open notification links in new tab on middle/ctrl-click#278

Open
henlein wants to merge 1 commit into
taigaio:mainfrom
henlein:fix-notifications-middle-click
Open

fix(notifications): open notification links in new tab on middle/ctrl-click#278
henlein wants to merge 1 commit into
taigaio:mainfrom
henlein:fix-notifications-middle-click

Conversation

@henlein

@henlein henlein commented Jun 15, 2026

Copy link
Copy Markdown

Summary

Fixes #228.

On the Notifications page, middle-clicking (or ctrl/cmd-clicking) a notification link opened the Taiga home page instead of the linked issue / user story / task. A normal left-click worked, but only because navigation was wired through an ng-click handler.

Root cause

Notification links are generated with an empty href — the real target URL is only placed in an ng-click handler:

# notifications.service.coffee — _getLink (used for the user, project and object links)
$('<a href="">')
  .attr('ng-click', "vm.setAsRead(notification, \"#{url}\")")

The same empty-href pattern is used for the inline project link in notifications-list.jade. Because index.jade declares <base href="/">, an empty href resolves to the site root. A left-click is intercepted by ng-click and navigates correctly, but middle-click and ctrl/cmd-click bypass the JS handler and follow the (empty → root) href, landing on the home page.

Fix

Give the anchors a real href (the same URL already passed to setAsRead) and forward $event to setAsRead:

  • Plain left-clicksetAsRead calls event.preventDefault() and navigates within the SPA via $location.path(url) (unchanged behaviour; no full page reload).
  • Middle-click / ctrl / cmd / shift — the click falls through to the browser, which opens the real href in a new tab/window.

Files changed:

  • app/modules/notifications/notifications.service.coffee_getLink emits a real href and forwards $event.
  • app/modules/notifications/notifications.controller.coffeesetAsRead accepts $event and only preventDefaults a plain left-click.
  • app/modules/notifications/notifications-list/notifications-list.jade — the .entry-project link uses ng-href instead of href="".

Testing

Manual, on the /notifications page:

  • Left-click a notification → navigates to the item in the same tab and marks it read (as before).
  • Middle-click → opens the item in a new tab (previously opened the home page). ✅
  • Ctrl/Cmd-click → opens the item in a new background tab (previously opened the home page). ✅
  • The project-name link under each entry behaves the same way.

Note: on modern browsers a pure middle-click does not fire a click event (it fires auxclick), so the item opens in the new tab but the source notification is not marked read on middle-click. This is inherent to the browser event model, not a regression in this change.


Prepared with AI assistance (Claude) and reviewed by the submitter, who signs off under the DCO.

…-click

Notification links were rendered as `<a href="">` with the target URL only in
an ng-click handler. Combined with `<base href="/">`, the empty href resolves
to the site root, so middle-click and ctrl/cmd-click - which bypass the JS
handler - opened the home page instead of the issue/story/task.

Give the anchors a real href and pass $event to setAsRead: a plain left-click
still navigates inside the SPA (preventDefault avoids a full reload), while
modifier/middle clicks fall through to the browser's native new-tab handling.

Fixes taigaio#228

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Alexander Henlein <50662522+henlein@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MMB click in the notifications page goes to home

1 participant