Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion resources/js/components/fieldtypes/bard/BardFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export default {
pageHeader: null,
escBinding: null,
showAddSetButton: false,
hasBeenFocused: false,
provide: {
bard: this.makeBardProvide(),
bardSets: this.config.sets,
Expand Down Expand Up @@ -745,7 +746,10 @@ export default {
enablePasteRules: this.config.enable_paste_rules,
editorProps: { attributes: { class: 'bard-content' } },
onDrop: () => this.debounceNextUpdate = false,
onFocus: () => this.$emit('focus'),
onFocus: () => {
this.hasBeenFocused = true;
this.$emit('focus');
},
onBlur: () => {
// Since clicking into a field inside a set would also trigger a blur, we can't just emit the
// blur event immediately. We need to make sure that the newly focused element is outside
Expand Down Expand Up @@ -977,6 +981,7 @@ export default {
Object.defineProperties(bard, {
setConfigs: { get: () => this.setConfigs },
isReadOnly: { get: () => this.readOnly },
hasBeenFocused: { get: () => this.hasBeenFocused },
});
return bard;
},
Expand Down
6 changes: 5 additions & 1 deletion resources/js/components/fieldtypes/bard/Set.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// We’re styling a Set so that it shows a “selection outline” when selected with the mouse or keyboard.
// 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).
// This prevents the outer selection outline from showing while the user is actively working inside the Set.
'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,
'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,
'border-red-500': hasError,
}"
:data-type="config.handle"
Expand Down Expand Up @@ -255,6 +255,10 @@ export default {
return this.decorationSpecs.withinSelection;
},

showSelectionHighlight() {
return (this.selected || this.withinSelection) && this.bard.hasBeenFocused;
},

fieldVm() {
return this.extension.options.bard;
},
Expand Down