Skip to content

fix: Location Field Aria Disabled Fix Logic - #984

Open
nikkisato wants to merge 5 commits into
opentripplanner:masterfrom
nikkisato:location-field-fix-aria-disabled
Open

nikkisato wants to merge 5 commits into
opentripplanner:masterfrom
nikkisato:location-field-fix-aria-disabled

Conversation

@nikkisato

@nikkisato nikkisato commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

This is a follow up ticket to fix my mistake on #948

Amy made a comment that menuItemCount would always be === 1
#948 (comment)

thought my solution would fix this since it was on mac that we found this issue

But after testing I think this solution works

I also added a desktop story of suppressNearby since that what we are using on our side

i also copied the accessibility overrides for the storybook from desktop to mobile was getting some error

The goal was to make sure that there was

  • no regression

  • on location unavailable (it will still appear saying current location not available)

image
  • on SuppressNearby there is no open box (please note this is the before the fix i just wanted to show what i mean by open box)
image

@nikkisato
nikkisato force-pushed the location-field-fix-aria-disabled branch from b82da36 to 84b8a47 Compare August 10, 2026 18:22
@nikkisato

Copy link
Copy Markdown
Contributor Author

Tagging miles here @miles-grant-ibigroup for review

@miles-grant-ibigroup miles-grant-ibigroup self-assigned this Aug 12, 2026

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little weary of some of the performance implications of all these extra checks, as well as introducing react props into the CSS render. However, I'm not entirely sure what the desired outcome of this PR is. Maybe @amy-corson-ibigroup could help?

If there is no other way to be a11y friendly I guess we could live with the performance hit, but it's a measurable 20-50ms in my testing which I think deserves a closer look

Comment on lines 1032 to +1037
if (!suppressNearby) {
if (!positionUnavailable) {
// Add to the selection handler lookup (for use in onKeyDown)
pushToIndexedOptions(locationSelected, optionId);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this have the byproduct of position warnings never appearing when suppressNearby is active?

@nikkisato nikkisato Aug 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**

  • If true, do not show nearbyStops or current location as options
    /
    suppressNearby?: boolean;
    /
    *

for the warnings there was only one that i was aware and it's still working

Screenshot 2026-08-13 at 9 58 25 AM

Yes I believe that would be true but i'm not sure how to get a storybook with suppressNearby and location unavaliable will take a look into that

@amy-corson-ibigroup

Copy link
Copy Markdown
Contributor

Hello! Just flagging that I see this and I will review this week

@amy-corson-ibigroup

amy-corson-ibigroup commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Hello, I'm really sorry for the delay! We've had devs on vacation, I had to take unexpected time off yesterday, and I am now at a client onsite, so I haven't given this the attention it deserves.

It looks like we're applying aria-disabled to the toggle when the toggle can open a menu with the "location unavailable" message. This doesn't feel like an accessibility improvement because sighted users now have access to information that AT users do not:

image

Would you also elaborate on the bug you're seeing or the situation you're encountering that suppressNearby prop seeks to solve? My original understanding of #948 was that we want to disable an irrelevant toggle for AT users (which I agree with), but it feels like with the suppression of certain menuItems from the results list, the scope has changed and I think I'm struggling to understand why.

@amy-corson-ibigroup amy-corson-ibigroup removed their assignment Aug 25, 2026
@nikkisato

Copy link
Copy Markdown
Contributor Author

@amy-corson-ibigroup

I want to step back and describe the two issues we were trying to fix, because I think my earlier approach blurred them together.

You're right about aria-disabled: applying it when the menu still shows "location unavailable" isn't an accessibility win. Sighted users see that message; disabling the toggle can block screen reader users from the same info. I'll remove that.

Two issues we were fixing (I blurred them before):

#1 ) Toggle activates but nothing happens — aria-expanded stayed true with no selectable options.
#2) Icon lacks unavailable state — sighted users saw the message; assistive technology got no clear signal.
Updated approach (aligned with #948):

aria-expanded="false" when there are no selectable options → fixes #1
Unavailable state via aria-expanded="false" + role="status"; toggle stays activatable → fixes #2
aria-disabled="true" only when the menu is completely empty (irrelevant toggle)

On suppressNearby: Not original #948 scope — came up because TriMet uses it. We found the selectable lookup still counted a suppressed current-location entry. aria-disabled only applies there when the menu is literally empty.

Proposed changes:

  • Don't push disabled "current location unavailable" into the selectable lookup
  • aria-expanded="false" when there are no selectable options
  • aria-disabled="true" only when the menu is completely empty — not when the unavailable message is showing
  • Keep the toggle enabled for Location Unavailable so assistive technology users can open the menu; unavailable text via existing role="status"
  • Keep $menuOpen CSS so the message stays visible when aria-expanded is false

@nikkisato

Copy link
Copy Markdown
Contributor Author

@miles-grant-ibigroup @amy-corson-ibigroup
Ready for review!

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick comment, but otherwise I think things look good from my end! But I haven't checked through what @amy-corson-ibigroup mentioned

const showMenuList = isStatic || menuItems.length > 0;
const listBoxControls = showMenuList ? listBoxId : undefined;

const statusAnnouncementText = statusMessages.filter(Boolean).join(". ");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes problems in some languages (especially RTL languages). However, I'd be ok to merge this as-is if we add a TODO on here and the other line where we manually concatenate a string!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants