Skip to content

Middle-clicking an icon-only Safari favorite opens it again - #1496

Closed
kzaoaai wants to merge 1 commit into
linearmouse:mainfrom
kzaoaai:autoscroll-favicon
Closed

kzaoaai wants to merge 1 commit into
linearmouse:mainfrom
kzaoaai:autoscroll-favicon

Conversation

@kzaoaai

@kzaoaai kzaoaai commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

With Auto Scroll on the middle button, middle-clicking an icon-only bookmark in Safari's Favorites bar starts Auto Scroll instead of opening the bookmark in a new tab. Bookmarks with a title and bookmark folders are not affected, and neither are links and tabs.

Cause

Safari's accessibility hit test for an icon-only bookmark returns its favicon: an AXImage whose AXParent is the Favorites bar group, not the bookmark's AXMenuButton. The button is a sibling of the image in the bar's children. Walking up from the image never reaches a pressable control, so the classifier reports the click as non-pressable. For a titled bookmark the hit lands on the AXMenuButton itself, which is why those work.

Seen with Safari 27.2 on macOS 27.2: the hit path was AXImage -> AXGroup -> AXWindow/AXStandardWindow -> AXApplication, and the bar's children are one AXMenuButton per bookmark, each with AXPress.

Fix

When the hit is an AXImage and its parent is not pressable either, the classifier looks among the parent's children for a pressable control whose frame contains the point, and treats the click as pressable when it finds one. The scan only runs for image hits, reads each child's role before its frame, and stops after 128 children. Clicks in the gaps between bookmarks still start Auto Scroll, because the hit there is the bar itself.

Testing

  • Three new classifier tests use a small accessibility tree double: a favicon over a bookmark button resolves to pressable; an image with no pressable control under the point stays non-pressable; a non-image hit never scans siblings. All 1200 app tests pass.
  • Tested by hand in Safari 27.2 on macOS 27.2: middle-clicking an icon-only Favorites bar bookmark now opens it in a new tab, and the log shows AXImage -> AXGroup -> child:AXMenuButton[press]. Titled bookmarks, tabs and links behave as before. Against the live Favorites bar (25 items) the extra scan took a few milliseconds.

🤖 Generated with Claude Code

Safari's Favorites bar hit-tests an icon-only bookmark to its favicon:
an AXImage whose parent is the bar itself, not the bookmark's
AXMenuButton. Walking up from the image never reaches a pressable
control, so Auto Scroll started instead of the native middle click
that opens the bookmark in a new tab. Bookmarks with a title and
folders were unaffected, because the hit lands on the button.

When the hit is an AXImage and its parent is not pressable either,
look among the parent's children for a pressable control whose frame
contains the point, and treat the hit as pressable when one does.
The scan only runs for image hits, reads roles before frames, and
is bounded to 128 children.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When the initial accessibility hit is an image, the classifier checks up to 128 children of its parent for a pressable control whose frame contains the hit point. Tests cover matching siblings, non-matching siblings, and static-text hits.

Changes: Image Sibling Classification

Layer / File(s) Summary
Bounded sibling lookup and validation
LinearMouse/Accessibility/AutoScrollAccessibilityActivationClassifier.swift, LinearMouseUnitTests/Accessibility/AutoScrollAccessibilityActivationClassifierTests.swift
The classifier records the initial hit role and scans up to 128 parent children when that role is AXImage. A qualifying sibling is added to the path and yields a pressable result. Tests cover matching and non-matching siblings, static-text hits, and accessibility-tree queries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested labels: bug

Suggested reviewers: lujjjh

Merge Risk: Minimal · up to 10095

The change adds a bounded lookup for icon-only Favorites. No actionable merge-blocking risk was established.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: fixing middle-click behavior for icon-only Safari favorites.
Description check Passed The description directly explains the Safari accessibility hit-test issue, the sibling-scan fix, scope, and test results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a1e33ed and 10095d8.

Files selected for processing: 2

  • LinearMouse/Accessibility/AutoScrollAccessibilityActivationClassifier.swift
  • LinearMouseUnitTests/Accessibility/AutoScrollAccessibilityActivationClassifierTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@lujjjh

lujjjh commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for tracking down the cause! Superseded by #1498, which fixes the same Favorites bar favicon hit with a bypass rule matching Safari's accessibility identifiers (FaviconImageView inside FavoritesBarView) instead of scanning siblings, so images in web pages don't pay for the extra queries. You're credited as a co-author on the commit.

@lujjjh lujjjh closed this Nov 6, 2026
lujjjh added a commit that referenced this pull request Nov 6, 2026
…d of starting Auto Scroll (#1498)

With Auto Scroll on the middle button, middle-clicking the favicon of a
bookmark in Safari's Favorites bar starts Auto Scroll instead of opening
the bookmark in a new tab. Middle-clicking the bookmark's title works.

## Cause

Safari's accessibility hit test for the icon returns an `AXImage`
(`FaviconImageView`) whose parent is the Favorites bar group
(`FavoritesBarView`), not the bookmark's `AXMenuButton`. The button is a
sibling of the image, so walking up from the image never reaches a
pressable control.

## Fix

A new bypass rule, `safariFavoritesBarFavicon`, treats a direct hit on
an `AXImage` with identifier `FaviconImageView` whose parent's
identifier starts with `FavoritesBarView` as pressable. Bypass rules
gain `identifier` and `parentIdentifierHasPrefix` conditions. The
classifier reads `AXIdentifier` only for `AXImage` elements, and the
parent's identifier only when the hit itself is an image with an
identifier, so elements in web content cost at most one extra query.

Compared with #1496, this matches the element Safari exposes instead of
scanning siblings by geometry, so it does not query the children of
images in web pages and does not change how images in other apps are
classified.

Supersedes #1496.

## Testing

- New rule tests cover a match, a parent outside the Favorites bar, and
a hit that is not direct.
- Tested by hand in Safari: middle-clicking a Favorites bar icon opens
the bookmark in a new tab; middle-clicking empty space in the bar and
images in web pages still starts Auto Scroll.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: kzaoaai <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@kzaoaai
kzaoaai deleted the autoscroll-favicon branch November 6, 2026 16:25
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.

2 participants