Skip to content

Commit

Permalink
Accessibility : Add title / target attributes to "my account" action …
Browse files Browse the repository at this point in the history
…link
  • Loading branch information
boulch committed Feb 26, 2025
1 parent 320d52d commit db3336d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.2.91 (unreleased)
-------------------

- Nothing changed yet.
- Accessibility : Add title / target attributes to "my account" action link
[boulch]


1.2.90 (2025-02-24)
Expand Down
10 changes: 10 additions & 0 deletions src/imio/smartweb/core/viewlets/actions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-

from imio.smartweb.locales import SmartwebMessageFactory as _
from plone import api
from plone.app.layout.viewlets import common
from zope.component import getMultiAdapter
from zope.i18n import translate
from zope.viewlet.interfaces import IViewletManager


Expand All @@ -10,7 +13,14 @@ def update(self):
context_state = getMultiAdapter(
(self.context, self.request), name="plone_context_state"
)
language = api.portal.get_current_language(context=self.context)
self.actions = context_state.actions("header_actions")
for action in self.actions:
if action["id"] == "account":
action["link_target"] = "_blank"
desc = translate(_(action["description"]), target_language=language)
new_tab = translate(_("New tab"), target_language=language)
action["description"] = f"{desc} ({new_tab})"


class HeaderActionsContainerViewlet(common.ViewletBase):
Expand Down
2 changes: 2 additions & 0 deletions src/imio/smartweb/core/viewlets/header_actions.pt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<a href="#"
tal:define="icon nocall:link/icon"
tal:attributes="class link/id;
target link/link_target;
title link/description;
href link/url;">
<span tal:condition="not:icon"
tal:content="link/title">
Expand Down

0 comments on commit db3336d

Please sign in to comment.