lila icon indicating copy to clipboard operation
lila copied to clipboard

Made "Learn from your mistakes" accessable in the NVUI.

Open nicvagn opened this issue 6 months ago • 1 comments

Made "Learn from your mistakes" accessible in the NVUI.

I also made the tags that function as

Screen readers have trouble with tags controlled via js.

If the button element rendering is not desired, it can be fixed with css. image (A image of the Computer analysis before learn from your mistakes) image (A image of the Computer analysis post learn from your mistakes)

edit: https://github.com/lichess-org/lila/issues/17621

nicvagn avatar Jun 14 '25 17:06 nicvagn

image how it renders in typical ui I am not offended by it, but can change it if requested.

nicvagn avatar Jun 14 '25 19:06 nicvagn

No longer fudges the vui.

nicvagn avatar Jun 19 '25 15:06 nicvagn

a lot of unnecessary structure and remnants from the visual ui remain in the pasted nvui snabbdom. element classes for visual styling should be avoided here, and flatten the element structure when possible.

jonbgamble avatar Jun 21 '25 11:06 jonbgamble

Yes, I am guilty of not really understanding snapdom, or what makes a good nvui.

When I return from camp I will give it another look.

Thanks for your time

nicvagn avatar Jun 21 '25 17:06 nicvagn

no sweat. when you get back to it, take a look at the nvuiInsertHook function. i'm not sure why focus would be called there when el was the keydown/click event target. under normal conditions that would indicate el === document.activeElement. but i left it in case you were seeing something weird with screen readers and that was the fix. who knows with nvui.

jonbgamble avatar Jun 21 '25 23:06 jonbgamble

Yes, the screen reader was focusing the top of the screen. When you toggled learn from your mistakes.

It was the a fix for that.

nicvagn avatar Jun 22 '25 19:06 nicvagn

i think this was happening because you were first drawing the button in analyse.nvui.ts, and then you were having retroView draw it. so the original element disappeared and thus the focus changed. it might be safe to remove the focus call now.

jonbgamble avatar Jun 23 '25 03:06 jonbgamble

I do not think the screen reader cares at all about javascript, right? It should only care about the rendered html, at least that is my understanding of the technology.

I will give it a try in the am. Good night.

nicvagn avatar Jun 23 '25 03:06 nicvagn

I do not think the screen reader cares at all about javascript, right? It should only care about the rendered html

javascript is rendering the html.

jonbgamble avatar Jun 23 '25 03:06 jonbgamble

Yes, I understand that.

But what I mean is that the rendering of the html should have referential transparency, no?

The rendering should not have any side effects, in my thoughts.

:. It should not matter what function renders the html.

I don't know if my assumption about the lack of side effects is true.

nicvagn avatar Jun 23 '25 04:06 nicvagn

It should not matter what function renders the html.

you need to learn about snabbdom

jonbgamble avatar Jun 23 '25 05:06 jonbgamble

long story short, it only creates new elements when it has to. like when the html structure changes, such as ~~a different class on a button or~~ a slightly different ancestor hierarchy.

when that happens, the old element is removed from the dom and the new ones are patched in. if a removed element had focus, then focus is reset. if it's still in the DOM then it will retain focus.

Edit: adding/removing a class will not trigger removal

jonbgamble avatar Jun 23 '25 05:06 jonbgamble

Ok, I think I understand. I will work on it after I take a nap.

Are there any resources you can recommend for me to fix my understanding?

Thanks a bunch, sorry for assuming. You know what they say...

nicvagn avatar Jun 23 '25 19:06 nicvagn

I had no understanding that the js was adjusting the elements in focus. So rendering does not have rt.

nicvagn avatar Jun 23 '25 19:06 nicvagn

referential transparency is not a common expectation in front end land. javascript/html/css behavior is about as far from pure functional programming as one can get.

with snabbdom, every time we call redraw, we re-render the entire page as lightweight VNodes (short for virtual nodes) that correspond to the real DOM (which is expensive to modify). snabbdom then diffs the two and tries to do the absolute minimum to bring the real DOM into sync. if a property of a VNode changes, usually those changes can be carried over to the corresponding DOM element as modifications. but certain attributes, properties, and any ancestry change will cause removals and new elements to be patched into the DOM.

jonbgamble avatar Jun 24 '25 00:06 jonbgamble

Thanks, I will try not to assume things work a certain way without justification. I want to have heading elements in my buttons but want the click events to bubble up. I want the headings due to screen reader users navigating by them. I will work on this tomorrow. GN.

nicvagn avatar Jun 24 '25 02:06 nicvagn

you've changed a lot of things that aren't related to your feature. there's a lot of new assertives, asides, and <label>s have become headings now. i'm not sure how that will play, but is this in a state yet where ikrami1 can go over it? i can put it up on a test server that has a longer lifetime than gitpod.

jonbgamble avatar Jun 24 '25 22:06 jonbgamble

you've changed a lot of things that aren't related to your feature. there's a lot of new assertives, asides, and

That was done in my possibly misguided attempt to ""improve"" the html to be more semantic.

If it is unwanted, I can quite easily change.

If is ready for testing by screen reader users. Thank you for your help, it is appreciated.

The label to heading is done to increase usability via screen reader. ikrami1 stated people often navigate via heading when using a screen reader. I started doing this in my testing, and found it quite useful. labels do not have a corresponding functionality in screen readers to my knowledge. That was my reasoning.

As for this PR I do not like the unorganized state. I would like to close and figure out how to organize and open a new pr.

This one is still useful for the discussion. etc.

nicvagn avatar Jun 24 '25 23:06 nicvagn

The current state of nvui-learn-from-your-mistakes is ready for testing. I am sorry for my disorganization. If there are any changes ie: div -> aside that you would lika me to change, I would be happy to.

nicvagn avatar Jun 24 '25 23:06 nicvagn

I tried to cleanup, with no avail. I integrated changes into my "wip" tree.

nicvagn avatar Jun 25 '25 01:06 nicvagn