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

Use contentEditable for our hidden accessibility textArea #97154

Open
isidorn opened this issue May 7, 2020 · 12 comments
Open

Use contentEditable for our hidden accessibility textArea #97154

isidorn opened this issue May 7, 2020 · 12 comments
Assignees
Labels
accessibility Keyboard, mouse, ARIA, vision, screen readers (non-specific) issues editor-core Editor basic functionality under-discussion Issue is under discussion for relevance, priority, approach
Milestone

Comments

@isidorn
Copy link
Contributor

isidorn commented May 7, 2020

Investigate into using contenteditable instead of a plain textArea for our hidden accessibility field.
It migh have performance implications, but it would allow us to have richer accessibility content on each line. Including line number, breakpoints etc..

@isidorn isidorn added accessibility Keyboard, mouse, ARIA, vision, screen readers (non-specific) issues under-discussion Issue is under discussion for relevance, priority, approach labels May 7, 2020
@isidorn isidorn added this to the May 2020 milestone May 7, 2020
@isidorn isidorn self-assigned this May 7, 2020
@LeonarddeR
Copy link

cc @bramd @zersiax

Note that line number support will probably conflict with the ability of the screen reader to provide line numbers itself. NVDA is able to do this. In Visual Studio, this is also an issue.

@zersiax
Copy link

zersiax commented May 7, 2020

While that is true, I would say line numbers can be toggled, so I don't necessarily see that as an obstacle for this. If this allows for breakpoint, error and line number indication, I'd say go for at least giving it a test run. The performance implications are one to keep an eye on, though.

@derekriemer
Copy link

NVDA's line number reading is not going to work in vscode, because vscode can only page n lines at a time to the hidden textarea used for accessibility.

@isidorn isidorn modified the milestones: May 2020, June 2020 May 29, 2020
@isidorn
Copy link
Contributor Author

isidorn commented Jun 26, 2020

Unfortunetly I did not have time to look into this this milestone. In july I am on vacation, thus pushing this out to August.

@isidorn isidorn modified the milestones: June 2020, August 2020 Jun 26, 2020
@isidorn isidorn modified the milestones: August 2020, September 2020 Aug 28, 2020
@isidorn isidorn modified the milestones: September 2020, October 2020 Sep 28, 2020
@isidorn isidorn modified the milestones: October 2020, November 2020 Oct 26, 2020
@isidorn isidorn modified the milestones: November 2020, On Deck Nov 23, 2020
@MarcoZehe
Copy link
Contributor

@isidorn since you brought this up in another issue, did you have time at all yet to look into this?

@isidorn
Copy link
Contributor Author

isidorn commented Feb 22, 2021

@MarcoZehe yeah I found some time, however I hit some bigger issues with this approach. I believe none of them are unsolvable but they showed that this is a bigger effort. So we would use a HTMLDivElement instead of an HTMLTextArea, here are the issues I could not figure out:

  • How to get selection indexes of the HTMLDivElement. It does not have the selectionStart and selectionEnd like the textArea
  • I could not figure out how to set programatically setSelectionRange on an HTMLDivElement
  • Not sure if composition events would work nicely since I noticed that they do not work as expected on google docs. Composition we use when user is inputing Korean for example, or when holding the a to get the ä.

If somebody has ideas how to tackle these let me know. Especially the first two with selection.

@MarcoZehe
Copy link
Contributor

Does the contentEditable attribute not handle these automatically?

@isidorn
Copy link
Contributor Author

isidorn commented Feb 22, 2021

@MarcoZehe contentEditable indeed allows for the selection to be changed by the user and it will be automatically updated. However for us the contentEditable is not the truth it is hidden away beneath our editor.
So when the user changes the selection in our Editor we need to update the selection in the hidden contentEditable. And that is the reason why we have to manipulate the selection programatically.
Keep in mind that the selection in our editor is not a "real" HTML selection.

Hopefully I explained this correctly, let me know if not and I can try again :)

@yume-chan
Copy link
Contributor

For contentEditable elements, the Selection API (https://developer.mozilla.org/en-US/docs/Web/API/Selection) can be used to retrieve and manipulate selection programmatically.

It is more difficult to use than textarea, because Selection API manages selections on the whole page. Any element without user-select: none can be selected by user and the selection will be returned by Selection API. It may not be a problem in Code, but definitely need attention when Monaco is hosted in users' page.

@isidorn
Copy link
Contributor Author

isidorn commented Feb 23, 2021

@yume-chan that's a good idea, and if I am not mistaken I also tried with that, however I found that API to be much less powerful. Selection.addRange was a bit clunky to use with our model. Another problem was if the editor does not have focus and something is selected in another part of vcscode the underlying editor contentEditable selection should still work - and I am not sure that is the case.
However I should just try it out again and report here, instead of trying to remember what I did.

@LeonarddeR
Copy link

However for us the contentEditable is not the truth it is hidden away beneath our editor.

Probably a not too smart question, but what is holding you back from implementing something accessible in the true editor?

@isidorn
Copy link
Contributor Author

isidorn commented Feb 23, 2021

@LeonarddeR it's a good question. Because our true editor is a bunch of html divs, spans and what not. It is not only text, as there can be inline decorations and other details. it is not a textArea or an input field and screen readers do not really work well with our editor HTML structure. Also the cursor is not the real cursor, the selection is not the real html selection and so on.

I believe @alexdima the author of the editor considered this and he can probably explain in more detail if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Keyboard, mouse, ARIA, vision, screen readers (non-specific) issues editor-core Editor basic functionality under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants
@yume-chan @MarcoZehe @isidorn @LeonarddeR @zersiax @derekriemer @meganrogge and others