diff --git a/resources/js/components/fieldtypes/bard/BardFieldtype.vue b/resources/js/components/fieldtypes/bard/BardFieldtype.vue index 33e2e18842..5ef72b4821 100644 --- a/resources/js/components/fieldtypes/bard/BardFieldtype.vue +++ b/resources/js/components/fieldtypes/bard/BardFieldtype.vue @@ -208,6 +208,7 @@ export default { pageHeader: null, escBinding: null, showAddSetButton: false, + hasBeenFocused: false, provide: { bard: this.makeBardProvide(), bardSets: this.config.sets, @@ -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 @@ -977,6 +981,7 @@ export default { Object.defineProperties(bard, { setConfigs: { get: () => this.setConfigs }, isReadOnly: { get: () => this.readOnly }, + hasBeenFocused: { get: () => this.hasBeenFocused }, }); return bard; }, diff --git a/resources/js/components/fieldtypes/bard/Set.vue b/resources/js/components/fieldtypes/bard/Set.vue index 0df701732e..e7f6824eb7 100644 --- a/resources/js/components/fieldtypes/bard/Set.vue +++ b/resources/js/components/fieldtypes/bard/Set.vue @@ -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" @@ -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; },