fix(notifications): open notification links in new tab on middle/ctrl-click#278
Open
henlein wants to merge 1 commit into
Open
fix(notifications): open notification links in new tab on middle/ctrl-click#278henlein wants to merge 1 commit into
henlein wants to merge 1 commit into
Conversation
…-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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-clickhandler.Root cause
Notification links are generated with an empty
href— the real target URL is only placed in anng-clickhandler:The same empty-
hrefpattern is used for the inline project link innotifications-list.jade. Becauseindex.jadedeclares<base href="/">, an emptyhrefresolves to the site root. A left-click is intercepted byng-clickand 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 tosetAsRead) and forward$eventtosetAsRead:setAsReadcallsevent.preventDefault()and navigates within the SPA via$location.path(url)(unchanged behaviour; no full page reload).Files changed:
app/modules/notifications/notifications.service.coffee—_getLinkemits a realhrefand forwards$event.app/modules/notifications/notifications.controller.coffee—setAsReadaccepts$eventand onlypreventDefaults a plain left-click.app/modules/notifications/notifications-list/notifications-list.jade— the.entry-projectlink usesng-hrefinstead ofhref="".Testing
Manual, on the
/notificationspage:Note: on modern browsers a pure middle-click does not fire a
clickevent (it firesauxclick), 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.