-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[url_launcher][web] Link should work when triggered by keyboard (#6505)
### Background You can think of the `Link` widget (on the web) as two components working together: 1. The `<a>` element created by the `Link` widget. This is essential to make all browser interactions feel natural (e.g. context menu, cmd+click, etc). 2. The children of `Link` widget. These are the widgets visible to the user (e.g. a button or a hyperlink text) and the user can interact with them the same way they would interact with any Flutter widgets (focus, pointer click, etc). In order for the Link widget to navigate to a URI, the two components from above have to indicate their intent of navigation: 1. Some widget has to call `followLink` to indicate that the click successfully landed (i.e. hit tested) on it. E.g. if it's a button, then the `onPressed` callback should lead to a call to the Link's `followLink`. 2. The `<a>` element also has to receive an event to initiate the navigation. ### The PR We used to only handle click events on the `<a>` element, and no handling for keyboard events was present. So when a user tabs their way to the Link, then hits "Enter", the following happens: 1. The focused widget (e.g. button) that received the "Enter" will correctly indicate its intent to navigate by calling `followLink`. 2. The intent from the `<a>` element is lost because we were only handling clicks and not keyboard events. This PR adds handling of keyboard events so that it works similar to clicks. Fixes flutter/flutter#97863
- Loading branch information
Showing
4 changed files
with
331 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.