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

fix(core/form/inputs): fix issue with tabbing to popover toolbar buttons in PT-input #5057

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

skogsmaskin
Copy link
Member

@skogsmaskin skogsmaskin commented Oct 24, 2023

Description

There is currently an issue with reaching the annotation and inline object edit toolbar buttons with the keyboard.

This will make sure that when these toolbars shows, it will be possible to press Tab in order to get to the buttons with the keyboard.

Also added component tests for this.

What to review

That you are able to tab into the buttons when the toolbar is showing.

Notes for release

  • Fixed an issue with keyboard navigation to edit buttons for annotation and inline objects in the Portable Text Input.

@vercel
Copy link

vercel bot commented Oct 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:43pm
performance-studio ✅ Ready (Inspect) Visit Preview Dec 13, 2024 3:43pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:43pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:43pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 3:43pm

@skogsmaskin skogsmaskin changed the title Fix/pt input tab to toolbar fix(core/form/inputs): fix issue with navigating to toolbar buttons with keyboard Oct 24, 2023
@skogsmaskin skogsmaskin changed the title fix(core/form/inputs): fix issue with navigating to toolbar buttons with keyboard fix(core/form/inputs): fix issue with tabbing to popover toolbar buttons in PT-input Oct 24, 2023
@github-actions
Copy link
Contributor

No changes to documentation

@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2023

Component Testing Report Updated Dec 13, 2024 3:37 PM (UTC)

❌ Failed Tests (8) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 14s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 14s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 1m 22s 5 0 1
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 56s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 16s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ❌ Failed (Inspect) 4m 28s 0 0 6
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 15s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 3m 3s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 2m 13s 21 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 14s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 43s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ❌ Failed (Inspect) 2m 35s 20 0 1
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

@robinpyon robinpyon left a comment

Choose a reason for hiding this comment

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

Thanks @skogsmaskin, this is a huge improvement.

Just had a look and noticed a few things:

  1. When pressing TAB for the first time over an annotation, it will try focus the next element briefly before then focusing buttons within the popover.

If you look at this video and pay attention to the 'No items' box, you'll see what I mean:

Screenflick.Movie.30.mp4

I'm very certain this is the case due to buttonRef.current.focus() being wrapped within a setTimeout. This does seem like a bit of a smell!

One possible alternative is that rather than focusing the button directly, we create an invisible anchor element (with tabIndex=-1), and then on TAB:

  • initially focus the anchor element. Since it has tabIndex=-1, it will be ignored in sequential keyboard navigation
  • the browser will then 'naturally' tab to the next button in the list

Here's an example video with that approach:

Screenflick.Movie.31.mp4
  1. This popover doesn't trap focus – making it very easy to accidentally tab or shift-tab away completely out of the form. We should probably trap focus here.

  2. Focus isn't restored when closing the popover – ideally, closing the popover with ESC returns you exactly where you were.

We could probably punt on 2 + 3, but should capture these if we do.

@skogsmaskin skogsmaskin requested a review from a team December 18, 2023 18:19
@skogsmaskin skogsmaskin requested a review from a team as a code owner December 18, 2023 18:19
@skogsmaskin skogsmaskin requested review from ricokahler and removed request for a team December 18, 2023 18:19
@RitaDias
Copy link
Contributor

@skogsmaskin I'm assuming that this PR can be closed? 👀

@RitaDias RitaDias removed the request for review from a team June 27, 2024 06:15
@hermanwikner hermanwikner removed their request for review July 10, 2024 14:50
@skogsmaskin skogsmaskin force-pushed the fix/pt-input-tab-to-toolbar branch from 979a049 to 566e6b5 Compare December 12, 2024 01:42
@skogsmaskin skogsmaskin force-pushed the fix/pt-input-tab-to-toolbar branch from 566e6b5 to d8c8257 Compare December 12, 2024 09:38
@skogsmaskin skogsmaskin force-pushed the fix/pt-input-tab-to-toolbar branch 2 times, most recently from 566e6b5 to 1adfba8 Compare December 13, 2024 13:01
@skogsmaskin skogsmaskin removed the request for review from ricokahler December 13, 2024 13:14
…able Text Input

This will allow a user to purely use the keyboard when editing links and inline objects,
which was not possible before.
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