Skip to content

[6.x] Bard set selection/focus outline improvements - #14336

Merged
jackmcdade merged 25 commits into
6.xfrom
bard-focus-improvements
Oct 13, 2026
Merged

jackmcdade merged 25 commits into
6.xfrom
bard-focus-improvements

Conversation

@jaygeorge

Copy link
Copy Markdown
Contributor

Description of the Problem

Bard set selections can be confusing because focus states are shifted around with JavaScript.
This is documented in issue #14185 where a video shows the blue outline shifting around.

What this PR Does


  • Shifts some Tailwind outline classes to native CSS to make it easier to understand and edit
  • Simplify the outline state, removing an extra border in favour of just the pseudo element
  • Fix the selection outline when using the … dropdown so it's only shown around the set you're interacting with
  • Pause the focus outline while it settles, for example when the dropdown has just closed (open→closed), keep the outline hidden briefly so it doesn't flicker back to the parent while focus settles.
  • There was an issue on a couple of components where the focus state would drift back to the container—for example, with button groups, they would sometimes lose focus when they were clicked, so I've added a fix for that.

Before Fixes

Here you can see the selection outline is frequently pushed to the outer set when interacting with inner elements

Before.mp4

After Fixes

The selection outline does not jump to outer sets, instead keeping on the current set you're working on

After.mp4

How to Reproduce

Set up a Bard field with a set that houses a replicator, that contains a button group, and a further replicator (just for testing some inception replicators)

Try the following to see how the outline behaves:

  1. Click … in the inner replicator to access the dropdown. Currently, the outline selection will be pushed to the outer Bard field, which is misleading
  2. Try doing the same with the following, which have the same problem:
  3. The replicator expand/collapse controls
  4. Button groups
  5. A combobox open

duncanmcclean and others added 17 commits March 10, 2026 10:54
…den briefly so it doesn't flicker back to the parent while focus settles.
…roup] to prevent focus drifting back to container
…tline hidden briefly so it doesn't flicker back to the parent while focus settles." broken by the merge conflict
Comment thread resources/js/components/fieldtypes/bard/Set.js Outdated
# Conflicts:
#	resources/js/components/fieldtypes/bard/Set.vue
Match the readOnly prop added in 6.x, which also disables the button, so the
pointerdown and click focus helpers bail out in the same cases as disabled and
loading.
Focusing every Button on pointerdown broke anything relying on
@mousedown.prevent to keep focus elsewhere, like the Markdown floating
toolbar and Bard toolbar buttons. Re-focusing button group buttons after
every click also stole focus from modals and popovers app-wide.

- Button is back to matching 6.x
- The Bard set now focuses clicked buttons on mousedown (for Safari),
  skipping any mousedown that's already been prevented
- Button group buttons are only re-focused when focus has fallen back to
  the body or a wrapper, not when the click moved it somewhere on purpose
After we focus a clicked button on mousedown, Safari's default mousedown
action moves focus off it again, so the outer outline briefly reappears
until the button is re-focused. Prevent the default once the button has
focus so it stays put.
@jaygeorge
jaygeorge requested a review from jasonvarga October 8, 2026 10:41
@jackmcdade
jackmcdade enabled auto-merge (squash) October 13, 2026 21:01
@jackmcdade
jackmcdade disabled auto-merge October 13, 2026 23:52
@jackmcdade
jackmcdade removed the request for review from jasonvarga October 13, 2026 23:53
@jackmcdade
jackmcdade merged commit d59c330 into 6.x Oct 13, 2026
64 checks passed
@jackmcdade
jackmcdade deleted the bard-focus-improvements branch October 13, 2026 23:53
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.

Confusing UX in bard sets and removing sets is too easy

4 participants