Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to intercept keyboard events on gutter (with enableKeyboardAccessibility enabled) #5200

Closed
2 tasks
avinashbot opened this issue Jun 9, 2023 · 6 comments · Fixed by #5202
Closed
2 tasks

Comments

@avinashbot
Copy link

Describe the feature

When the gutter is hovered or an annotation icon is clicked, the editor emits the gutterclick and showGutterTooltip events. We intercept these events to hide the original tooltip and display the annotations in our own external error/warning pane. We'd like to do the same for the annotations activated through the keyboard (when enableKeyboardAccessibility is enabled), but there currently doesn't seem to be a way to do that.

Use Case

Cloudscape's code editor is a wrapper around the ace editor. The annotations are displayed in a small expandable errors/warnings panel present in the status bar as an alternative to the annotation tooltips. We'd like to preserve this UX for keyboard users as well, but it's not currently technically possible.

Proposed Solution

We listen to gutterclick to determine which annotation was clicked on and showGutterTooltip to close the underlying tooltip. The new keyboard gutter handler would need to emit these events to support our use-case.

  • There would need to be a gutterclick equivalent for the keyboard handler end (or maybe it could be reused?)
  • showGutterTooltip seems to be a pretty input modality agnostic event name, so it seems reasonable to emit this from the keyboard handler as well.

Other Information

For context:

And thank you for introducing enableKeyboardAccessibility, it's a huge keyboard accessibility win for the editor :)

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

ACE version used

1.20.0

@akoreman
Copy link
Contributor

akoreman commented Jun 9, 2023

hey, thanks for reaching out. Trying to see what we would need to emit to help you out here. Looking at your code, seems you mainly need to know the row when a key is pressed on the gutter. Would emitting gutterkeydown something along the lines of what I sketched here help you out?

showGutterTooltip should already be emitted when opening a tooltip using the keyboard. We call GutterTooltip.showTooltip here which ends up here and should emit showGutterTooltip here. In my (admittedly, very brief) testing it seems to work, does it not work for you?

@akoreman akoreman added p2 and removed needs-triage labels Jun 9, 2023
@akoreman
Copy link
Contributor

I think I see why showGutterTooltip is not working for you. In the PR introducing the keyboard gutter controls we refactored the GutterTooltip a bit and accidentally switched the order of tooltip.show and editor._signal("showGutterTooltip") preventing you from hiding the tooltip before it's shown. I'll fix that.

@akoreman
Copy link
Contributor

akoreman commented Jun 10, 2023

Did some testing and as far as I can tell, the change I sketched above should allow you to do what you want:

ezgif-3-e405a4aeed.mp4

@avinashbot
Copy link
Author

A gutterkeydown event sounds perfect! One potential caveat would be that we would move focus when handling that event, so it would need to be emitted after ace does any focus handling on its own end.

@akoreman
Copy link
Contributor

The changes will be released in the next Ace release.

@akoreman
Copy link
Contributor

Has been released as part of Ace 1.23.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants