Make VoiceOver announce the article view feed icon as a Get Feed Info button. Fixes #4591.

This commit is contained in:
Brent Simmons committed 2026-07-27 21:48:45 -07:00
1 parent be1965c87c
commit 0e8bbf43e5
2 files changed
+28 -2

No files matched your search

@@ -120,11 +120,26 @@ private extension WebViewConfiguration {
let filenames = ["main", "main_mac", "newsfoot"]
#endif
let scripts = filenames.map { filename in
var scripts = filenames.map { filename in
let scriptURL = Bundle.main.url(forResource: filename, withExtension: ".js")!
let scriptSource = try! String(contentsOf: scriptURL, encoding: .utf8)
return WKUserScript(source: scriptSource, injectionTime: .atDocumentStart, forMainFrameOnly: true)
}
#if os(iOS)
scripts.insert(feedInfoLabelScript, at: 0)
#endif
return scripts
}()
#if os(iOS)
// main_ios.js uses nnwGetFeedInfoLabel as the feed icon's accessibility label.
// The label is passed in from here because localized strings can't live in a static .js file.
// JSON encoding escapes the translation so it's a valid JavaScript string literal.
static let feedInfoLabelScript: WKUserScript = {
let label = NSLocalizedString("Get Feed Info", comment: "Get Feed Info")
let json = String(data: try! JSONSerialization.data(withJSONObject: label, options: .fragmentsAllowed), encoding: .utf8)!
return WKUserScript(source: "const nnwGetFeedInfoLabel = \(json);", injectionTime: .atDocumentStart, forMainFrameOnly: true)
}()
#endif
}
+12 -1
View File
@@ -133,7 +133,18 @@ function showClickedImage() {
}
function showFeedInspectorSetup() {
document.getElementById("nnwImageIcon").onclick = function(event) {
const imageIcon = document.getElementById("nnwImageIcon");
if (!imageIcon) {
return;
}
// Tell VoiceOver the icon is a button that opens the Feed Info sheet.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/4591>
imageIcon.setAttribute("role", "button");
imageIcon.setAttribute("tabindex", "0");
imageIcon.setAttribute("aria-label", nnwGetFeedInfoLabel);
imageIcon.onclick = function(event) {
window.webkit.messageHandlers.showFeedInspector.postMessage("");
}
}