Skip to content

[APP-527] feat: add keyboard nav to advanced filter drag and drop#3213

Open
mcmcgrath13 wants to merge 9 commits into
mcm/adv-filt-uifrom
mcm/adv-filt-dnd-key
Open

[APP-527] feat: add keyboard nav to advanced filter drag and drop#3213
mcmcgrath13 wants to merge 9 commits into
mcm/adv-filt-uifrom
mcm/adv-filt-dnd-key

Conversation

@mcmcgrath13
Copy link
Copy Markdown
Contributor

Description

Add keyboard-nav drag and drop to the advanced filter builder

Notes:

  • Originally thought using dnd-kit adapter would be easiest since it has a keyboard sensor, but as time went on I realized that driving the dragging via keyboard was pretty painful/finnicky and we know what we want to happen, so we can just move things directly
  • There's a shift button ux build into the query builder, but it adds even more buttons which isn't great, but looked at how it was implemented to create our bespoke drag handle with what we need
  • Because of react re-mounting when a rule group changed level, needed to keep track of what drag handle is active at any given time so we can restore focus there when things move
  • Changed the adapter to the atlaskit one as I generally found it smoother/more intuitive (and didn't want keyboard handlers to clash)

Tickets

Checklist before requesting a review

  • PR focuses on a single story
  • Code has been fully tested to meet acceptance criteria
  • PR is reasonably small and reviewable (Generally less than 10 files and 500 changed lines)
  • All new functions/classes/components reasonably small
  • Functions/classes/components focused on one responsibility
  • Code easy to understand and modify (clarity over concise/clever)
  • PRs containing TypeScript follow the Do's and Don'ts
  • PR does not contain hardcoded values (Uses constants)
  • All code is covered by unit or feature tests

@mcmcgrath13 mcmcgrath13 requested a review from a team as a code owner May 7, 2026 21:12
@mcmcgrath13 mcmcgrath13 requested review from emyl3 and krista-skylight and removed request for a team May 7, 2026 21:12
@emyl3
Copy link
Copy Markdown
Contributor

emyl3 commented May 8, 2026

(❓, maybe b) It feels like we should override the default of scrolling when we hit the spacebar when we're focused on that element to toggle it. What do you think, Mary?

screen_recording.mov

@mcmcgrath13
Copy link
Copy Markdown
Contributor Author

(❓, maybe b) It feels like we should override the default of scrolling when we hit the spacebar when we're focused on that element to toggle it. What do you think, Mary?

Nice find! pushed up a fix

};

return (
<span
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for addressing the other issue! 🤩
(❓) Another thing that came up... If a user tabs away from the drag and drop toggle with the toggle being on and then they return to it, the toggle is still on which could be confusing.

Question 1: Should we auto turn off the toggle when they navigate away? Or leave it on?

There's nothing that seems to indicate it is on/off visually and with like an aria-label or something like that. I also tried navigating this using Mac's VoiceOver utility and nothing was obvious.

Question 2: Should we add something here to address this visually and not visually? (Or would that be a separate ticket?)

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.

Excellent question! I'm going to work on making this match the experience for keyboard nav drag and drop on the patient search column preferences

@mcmcgrath13 mcmcgrath13 requested a review from emyl3 May 11, 2026 21:58
@sonarqubecloud
Copy link
Copy Markdown

import styles from './VisuallyHidden.module.scss';

// From https://www.joshwcomeau.com/snippets/react-components/visually-hidden/
// Display text for screen readers only, but in dev mode can hold `Alt` to display the value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 that's very neat/handy!!

const [isActive, setIsActive] = useState<boolean>(activeId === id);
const { getQuery, dispatchQuery } = props.schema;

// When a rule group changes level, the component re-mounts and we need to move focus
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see why we need to re-focus... From my testing around, it looks like doing that is causing this message to be read again in VoiceOver which means that the message of moving the element can get missed...

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.

We could leave that as hidden description text in the front matter of the section, but not make it describe each drag handle? That relies on the user going through that content on the way to the widget - not sure if that's a better or worse UX as I can argue it either way @kenieh any thoughts here?

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.

2 participants