Skip to content

Commit 70e93f2

Browse files
[6.x] Avoid showing selected state on sets unless user has interacted with Bard (#13570)
1 parent 6180b85 commit 70e93f2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

resources/js/components/fieldtypes/bard/BardFieldtype.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export default {
208208
pageHeader: null,
209209
escBinding: null,
210210
showAddSetButton: false,
211+
hasBeenFocused: false,
211212
provide: {
212213
bard: this.makeBardProvide(),
213214
bardSets: this.config.sets,
@@ -745,7 +746,10 @@ export default {
745746
enablePasteRules: this.config.enable_paste_rules,
746747
editorProps: { attributes: { class: 'bard-content' } },
747748
onDrop: () => this.debounceNextUpdate = false,
748-
onFocus: () => this.$emit('focus'),
749+
onFocus: () => {
750+
this.hasBeenFocused = true;
751+
this.$emit('focus');
752+
},
749753
onBlur: () => {
750754
// Since clicking into a field inside a set would also trigger a blur, we can't just emit the
751755
// blur event immediately. We need to make sure that the newly focused element is outside
@@ -977,6 +981,7 @@ export default {
977981
Object.defineProperties(bard, {
978982
setConfigs: { get: () => this.setConfigs },
979983
isReadOnly: { get: () => this.readOnly },
984+
hasBeenFocused: { get: () => this.hasBeenFocused },
980985
});
981986
return bard;
982987
},

resources/js/components/fieldtypes/bard/Set.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// We’re styling a Set so that it shows a “selection outline” when selected with the mouse or keyboard.
88
// The extra `&:not(:has(:focus-within))` rule turns that outline off if any element inside the Set has focus (e.g. when editing inside a Bard field).
99
// This prevents the outer selection outline from showing while the user is actively working inside the Set.
10-
'st-set-is-selected [&:not(:has(:focus-within))]:border-blue-400! [&:not(:has(:focus-within))]:dark:border-blue-400! [&:not(:has(:focus-within))]:before:content-[\'\'] [&:not(:has(:focus-within))]:before:absolute [&:not(:has(:focus-within))]:before:inset-[-1px] [&:not(:has(:focus-within))]:before:pointer-events-none [&:not(:has(:focus-within))]:before:border-2 [&:not(:has(:focus-within))]:before:border-blue-400 [&:not(:has(:focus-within))]:dark:before:border-blue-400 [&:not(:has(:focus-within))]:before:rounded-lg': selected || withinSelection,
10+
'st-set-is-selected [&:not(:has(:focus-within))]:border-blue-400! [&:not(:has(:focus-within))]:dark:border-blue-400! [&:not(:has(:focus-within))]:before:content-[\'\'] [&:not(:has(:focus-within))]:before:absolute [&:not(:has(:focus-within))]:before:inset-[-1px] [&:not(:has(:focus-within))]:before:pointer-events-none [&:not(:has(:focus-within))]:before:border-2 [&:not(:has(:focus-within))]:before:border-blue-400 [&:not(:has(:focus-within))]:dark:before:border-blue-400 [&:not(:has(:focus-within))]:before:rounded-lg': showSelectionHighlight,
1111
'border-red-500': hasError,
1212
}"
1313
:data-type="config.handle"
@@ -255,6 +255,10 @@ export default {
255255
return this.decorationSpecs.withinSelection;
256256
},
257257
258+
showSelectionHighlight() {
259+
return (this.selected || this.withinSelection) && this.bard.hasBeenFocused;
260+
},
261+
258262
fieldVm() {
259263
return this.extension.options.bard;
260264
},

0 commit comments

Comments
 (0)