0

I do not see when a listbox gets focus (by keyboard)

asked 2023-06-29 23:32:43 +0800

holos gravatar image holos
27 5

updated 2023-07-03 16:32:24 +0800

ZK-EE 9.6.1 / Using Module za11y! for accessibility.

I have a listbox (bound to a ListModelList with single selection). I added a tabindex="0" to the <listindex /> element.

Now I can "tab" with the keyboard into the listbox. Cool.

But I do not see that happen. There is no visual clue that I entered the listbox.

As soon as I use the cursor-keys (up/down/left/right) the selected row gets highlighted (selected).

My Question: What do I have to change to let the user know (visually), that he entered the listbox and can start using the cursor-keys?

Funfact: If I use a grid there is a bright visual hint whenever the grid is entered via keyboard. But here the selected line(s) in the ListModelList are not highlighted. And: keyboard navigation does not happen with the arrow keys but with the tab key.

So if anybody could assist that would be greatly appreciated as obviously both variants fail for different reasons.

delete flag offensive retag edit

Comments

FYI I also updated the tracker ticket to reflect this topic: https://tracker.zkoss.org/browse/ZK-5486

MDuchemin ( 2023-07-04 15:00:24 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2023-07-08 01:33:40 +0800

MDuchemin gravatar image MDuchemin
2390 1 6
ZK Team

Thanks for pointing out the issue with pointer not working after applying style.

Turns out I forgot that the display element would catch pointer events :D

Here's a corrected style:

<style> 
.z-listbox:focus-within {
    position: relative;
}
.z-listbox:focus-within::before {
    z-index: 1;
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    box-shadow: inset 0 0 0 2px #E67626, inset 0 0 0 0px #FFFFFF;
    pointer-events: none;
}
</style>
link publish delete flag offensive edit

Comments

this version lets the pointer events go to the underlying component, so it should no longer prevent interaction with the listbox ;)

MDuchemin ( 2023-07-08 01:34:21 +0800 )edit

Yes, this works like a charm - thx a lot!

holos ( 2023-07-10 21:25:13 +0800 )edit
1

answered 2023-07-04 14:51:36 +0800

MDuchemin gravatar image MDuchemin
2390 1 6
ZK Team

Hey there,

Regarding the Grid, the explanation is fairly simple: Grid is not a selectable component. It just displays stuff in a table-like structure.

In contrast, the listbox does support selection and focus on individual rows.

As a result, the grid doesn't have any selection or manipulation workflow of grid rows.

Regarding Listbox:

I'm not clear as to what you mean by "adding tabindex="0" to the <listindex /> element". Could you provide a short code sample?

Listbox with za11y should already accept tab focus without modification. This said, I agree that it is not very visually nice that there is no default highlight of the focus position.

I think something like this would be appropriate: (add a border to the entire listbox while focus is located anywhere inside of it)

<style>
.z-listbox:focus-within {
    position: relative;
}
.z-listbox:focus-within::before {
    z-index: 1;
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    box-shadow: inset 0 0 0 2px #E67626, inset 0 0 0 0px #FFFFFF;
}
</style>
link publish delete flag offensive edit

Comments

Thanks for the answer: The answer to your question:

> I'm not clear as to what you mean by "adding tabindex="0" to the <listindex />

is exactly what you guessed: I thought I'd need tabindex="0" to make the listbox focusable but if this is not needed I'll give it a try.

holos ( 2023-07-04 15:51:26 +0800 )edit

And yes: unfortunately the visibility of a focussed listbox is poor. Would be nice to see an improvement here.

holos ( 2023-07-04 15:53:03 +0800 )edit

There is now a problem. As soon as I apply the css I can no longer select a listitem by clicking - only "enter" works. After clicking the entire listbox freezes. Even the scrollbar is no longer active. If I remove content: "" it works again - but then there is no focus frame.

holos ( 2023-07-06 04:44:11 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2023-06-29 23:32:43 +0800

Seen: 10 times

Last updated: Jul 08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More