Skip to content

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

Open
jaygeorge wants to merge 18 commits into6.xfrom
bard-focus-improvements
Open

[6.x] Bard set selection/focus outline improvements#14336
jaygeorge wants to merge 18 commits into6.xfrom
bard-focus-improvements

Conversation

@jaygeorge
Copy link
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 on lines +78 to +106
addKeyboardShortcuts() {
const shortcuts = {};
const type = this.type;

const isSetSelected = (state) => {
const { selection } = state;
return selection instanceof NodeSelection && selection.node.type === type;
};

const blockCharacterKey = () => isSetSelected(this.editor.state);

// Letters a-z
for (let i = 97; i <= 122; i++) {
shortcuts[String.fromCharCode(i)] = blockCharacterKey;
}

// Numbers 0-9
for (let i = 0; i <= 9; i++) {
shortcuts[String(i)] = blockCharacterKey;
}

// Common punctuation/symbols
[' ', '-', '=', '[', ']', '\\', ';', "'", ',', '.', '/', '`'].forEach(
(key) => (shortcuts[key] = blockCharacterKey),
);

return shortcuts;
},

Copy link
Member

Choose a reason for hiding this comment

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

This is wrong. Looks like you somehow grabbed mid-way through this PR #14189.

The PR ended up being different so these lines shouldn't be here at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I have no idea how that happened! I've updated the file so it's the same as the v6 branch now

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

3 participants