Bläddra i källkod

Ease keyboard navigation within article contents (#9643)

* After uncollapsing an article, the first element inside of it will be focused (the title link) for easier Tab navigation.
* All of the links inside entry headers (normal view) now use `tabindex="-1"`, so they can't be focused anymore using Tab. This makes navigation less confusing as there is JS functionality already for moving between articles (i.e. j/k keys) which is the intended way.
  * (or s/l for the Share or Labels menu)
* Focus rings are now visible again (removed `outline: none` from CSS for `<a>` elements).

This is mainly for the Normal view, but affects the Reader and Global views too.
Inverle 8 timmar sedan
förälder
incheckning
db2cc4a373

+ 2 - 0
CHANGELOG.md

@@ -4,6 +4,8 @@ See also [the FreshRSS releases](https://github.com/FreshRSS/FreshRSS/releases).
 
 ## 2026-1X-XX FreshRSS 1.31.1-dev
 
+* Features
+	* Ease keyboard navigation within article contents [#9643](https://github.com/FreshRSS/FreshRSS/pull/9643)
 * Security
 	* SimplePie: Fix regex in clean hash (security + bug for PHP < 8.4) [#9616](https://github.com/FreshRSS/FreshRSS/pull/9616), [GHSA-8pj8-6xgr-8r8f](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-8pj8-6xgr-8r8f)
 	* Harden SSRF guard: reject remaining reserved/special-use IP ranges [#9621](https://github.com/FreshRSS/FreshRSS/pull/9621),

+ 7 - 7
app/views/helpers/index/normal/entry_header.phtml

@@ -34,7 +34,7 @@
 				if ($this->entry->isRead()) {
 					$arUrl['params']['is_read'] = '0';
 				}
-				?><a class="item-element read" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_read') ?>"><?=
+				?><a tabindex="-1" class="item-element read" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_read') ?>"><?=
 					_i($this->entry->isRead() ? 'read' : 'unread'); ?></a><?php
 			?></li><?php
 		}
@@ -44,7 +44,7 @@
 				if ($this->entry->isFavorite()) {
 					$arUrl['params']['is_favorite'] = '0';
 				}
-				?><a class="item-element bookmark" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?=
+				?><a tabindex="-1" class="item-element bookmark" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?=
 					_i($this->entry->isFavorite() ? 'starred' : 'non-starred'); ?></a><?php
 			?></li><?php
 		}
@@ -52,7 +52,7 @@
 
 	if ($topline_website !== 'none'):
 	?><li class="item website">
-		<a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" class="item-element" title="<?= _t('gen.action.filter') ?>: <?= $this->feed->name() ?>">
+		<a tabindex="-1" href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" class="item-element" title="<?= _t('gen.action.filter') ?>: <?= $this->feed->name() ?>">
 			<?php if (FreshRSS_Context::userConf()->show_favicons && 'name' !== $topline_website): ?><img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?php endif; ?><?php if ('icon' !== $topline_website): ?><span class="websiteName"><?= $this->feed->name() ?></span><?php endif; ?>
 		</a>
 		</li><?php
@@ -68,7 +68,7 @@
 	?></li><?php
 	endif; ?>
 	<li class="item titleAuthorSummaryDate">
-		<a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element title" dir="auto"><?= $this->entry->title() ?><?php
+		<a tabindex="-1" target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element title" dir="auto"><?= $this->entry->title() ?><?php
 		if ($topline_display_authors):
 			?> <span class="author"><?= implode(' · ', $this->entry->authors()) ?></span><?php
 		endif;
@@ -83,7 +83,7 @@
 		<li class="item labels">
 			<div class="item-element dropdown dynamictags">
 				<div id="dropdown-labels2-<?= $this->entry->id() ?>" class="dropdown-target"></div>
-				<a class="dropdown-toggle" href="#dropdown-labels2-<?= $this->entry->id() ?>" title="<?= _t('index.menu.mylabels') ?>">
+				<a tabindex="-1" class="dropdown-toggle" href="#dropdown-labels2-<?= $this->entry->id() ?>" title="<?= _t('index.menu.mylabels') ?>">
 					<?= _i('label') ?>
 				</a>
 				<?php /* labels_article_template */ ?>
@@ -94,7 +94,7 @@
 		<li class="item share">
 			<div class="item-element dropdown">
 				<div id="dropdown-share2-<?= $this->entry->id() ?>" class="dropdown-target"></div>
-				<a class="dropdown-toggle" href="#dropdown-share2-<?= $this->entry->id() ?>" title="<?= _t('index.share') ?>">
+				<a tabindex="-1" class="dropdown-toggle" href="#dropdown-share2-<?= $this->entry->id() ?>" title="<?= _t('index.share') ?>">
 					<?= _i('share') ?>
 				</a>
 				<?php /* share_article_template */ ?>
@@ -105,7 +105,7 @@
 		if ($title_opens_website) {	// The title opens the original website, so this icon opens the article in FreshRSS instead
 			?><button type="button" class="item-element as-link" title="<?= _t('gen.action.read_in_freshrss') ?>"><?= _i('view-reader') ?></button><?php
 		} else {
-			?><a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?=
+			?><a tabindex="-1" target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?=
 				_t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a><?php
 		}
 	?></li><?php } ?>

+ 9 - 0
p/scripts/main.js

@@ -457,6 +457,11 @@ function loadLazyImages(rootElement) {
 	});
 }
 
+function focusArticleContent(new_active) {
+	// To ease navigation within article contents using the keyboard
+	new_active.querySelector('a.go_website')?.focus({ focusVisible: false, preventScroll: true });
+}
+
 function toggleContent(new_active, old_active, skipping) {
 	// If skipping, move current without activating or marking as read
 	if (!new_active) {
@@ -484,6 +489,7 @@ function toggleContent(new_active, old_active, skipping) {
 	if (old_active !== new_active) {
 		if (!skipping) {
 			new_active.classList.add('active');
+			focusArticleContent(new_active);
 		}
 		new_active.classList.add('current');
 		if (old_active) {
@@ -495,6 +501,9 @@ function toggleContent(new_active, old_active, skipping) {
 		}
 	} else {
 		new_active.classList.toggle('active');
+		if (!skipping && new_active.classList.contains('active')) {
+			focusArticleContent(new_active);	// Restore focus lost when the article was collapsed
+		}
 	}
 
 	const new_offsetTop = new_active.offsetTop;

+ 0 - 1
p/themes/Alternative-Dark/adark.css

@@ -59,7 +59,6 @@ html, body {
 /*=== Links */
 a, button.as-link {
 	color: var(--font-color-light);
-	outline: none;
 }
 
 a:hover .icon {

+ 0 - 1
p/themes/Alternative-Dark/adark.rtl.css

@@ -59,7 +59,6 @@ html, body {
 /*=== Links */
 a, button.as-link {
 	color: var(--font-color-light);
-	outline: none;
 }
 
 a:hover .icon {

+ 0 - 1
p/themes/Ansum/ansum.css

@@ -46,6 +46,5 @@ body.register {
 
 /*=== Links */
 a, button.as-link {
-	outline: none;
 	color: var(--main-first);
 }

+ 0 - 1
p/themes/Ansum/ansum.rtl.css

@@ -46,6 +46,5 @@ body.register {
 
 /*=== Links */
 a, button.as-link {
-	outline: none;
 	color: var(--main-first);
 }

+ 0 - 1
p/themes/Flat/flat.css

@@ -11,7 +11,6 @@ html, body {
 /*=== Links */
 a, button.as-link {
 	color: #2980b9;
-	outline: none;
 }
 
 /*=== Forms */

+ 0 - 1
p/themes/Flat/flat.rtl.css

@@ -11,7 +11,6 @@ html, body {
 /*=== Links */
 a, button.as-link {
 	color: #2980b9;
-	outline: none;
 }
 
 /*=== Forms */

+ 0 - 1
p/themes/Mapco/mapco.css

@@ -46,7 +46,6 @@ body.register {
 
 /*=== Links */
 a, button.as-link {
-	outline: none;
 	color: var(--main-first);
 }
 

+ 0 - 1
p/themes/Mapco/mapco.rtl.css

@@ -46,7 +46,6 @@ body.register {
 
 /*=== Links */
 a, button.as-link {
-	outline: none;
 	color: var(--main-first);
 }
 

+ 0 - 5
p/themes/Nord/nord.css

@@ -1068,11 +1068,6 @@ li.item.active {
 /*=== GENERAL */
 /*============*/
 
-/*=== Links */
-a, button.as-link {
-	outline: none;
-}
-
 /*=== Forms */
 option,
 optgroup {

+ 0 - 5
p/themes/Nord/nord.rtl.css

@@ -1068,11 +1068,6 @@ li.item.active {
 /*=== GENERAL */
 /*============*/
 
-/*=== Links */
-a, button.as-link {
-	outline: none;
-}
-
 /*=== Forms */
 option,
 optgroup {

+ 0 - 1
p/themes/Origine/origine.css

@@ -95,7 +95,6 @@ html, body {
 /*=== Links */
 a, button.as-link {
 	color: var(--font-color-link);
-	outline: none;
 }
 
 a:hover,

+ 0 - 1
p/themes/Origine/origine.rtl.css

@@ -95,7 +95,6 @@ html, body {
 /*=== Links */
 a, button.as-link {
 	color: var(--font-color-link);
-	outline: none;
 }
 
 a:hover,

+ 0 - 1
p/themes/Pafat/pafat.css

@@ -100,7 +100,6 @@ html, body {
 /*=== Links */
 a, .as-link, button.as-link {
 	color: var(--font-color-link-general);
-	outline: none;
 }
 
 /*=== Forms */

+ 0 - 1
p/themes/Pafat/pafat.rtl.css

@@ -100,7 +100,6 @@ html, body {
 /*=== Links */
 a, .as-link, button.as-link {
 	color: var(--font-color-link-general);
-	outline: none;
 }
 
 /*=== Forms */

+ 0 - 5
p/themes/Swage/swage.css

@@ -123,7 +123,6 @@ li.tree-folder span.title {
 
 a {
 	color: var(--color-text-nav);
-	outline: none;
 
 	&#btn-subscription {
 		width: 76%;
@@ -1617,10 +1616,6 @@ main.global {
 	}
 }
 
-button.as-link {
-	outline: none;
-}
-
 .dropdown-target:target ~ .btn.dropdown-toggle {
 	background-color: var(--color-background-nav-darker);
 }

+ 0 - 5
p/themes/Swage/swage.rtl.css

@@ -123,7 +123,6 @@ li.tree-folder span.title {
 
 a {
 	color: var(--color-text-nav);
-	outline: none;
 
 	&#btn-subscription {
 		width: 76%;
@@ -1617,10 +1616,6 @@ main.global {
 	}
 }
 
-button.as-link {
-	outline: none;
-}
-
 .dropdown-target:target ~ .btn.dropdown-toggle {
 	background-color: var(--color-background-nav-darker);
 }