Skip to content

Commit 430dba1

Browse files
committed
Merge branch '4.x' into 5.x
2 parents 0f1d3f4 + 8ebb8cc commit 430dba1

38 files changed

Lines changed: 532 additions & 80 deletions

File tree

packages/actions/dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/actions/resources/js/components/modals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export default ({ livewireId }) => ({
188188
requestAnimationFrame(() =>
189189
requestAnimationFrame(() =>
190190
this.$nextTick(() => {
191-
previouslyFocusedElement.focus({ preventScroll: false })
191+
previouslyFocusedElement.focus({ preventScroll: true })
192192
}),
193193
),
194194
)

packages/actions/resources/views/action-modal.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
:close-by-clicking-away="$actionIsModalClosedByClickingAway"
4343
:close-by-escaping="$actionIsModalClosedByEscaping"
4444
:description="$actionModalDescription"
45-
:focus-trap-returns-focus="false"
45+
:restores-focus="false"
4646
:extra-modal-window-attribute-bag="$actionExtraModalWindowAttributeBag"
4747
:extra-modal-overlay-attribute-bag="$actionExtraModalOverlayAttributeBag"
4848
:footer-actions="$actionModalFooterActions"

packages/actions/src/Action.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -890,13 +890,13 @@ protected function toOptimizedLinkHtml(): string
890890
$iconHtml = $icon ? generate_icon_html($icon, size: IconSize::Small)?->toHtml() : '';
891891
$hrefHtml = generate_href_html($url)->toHtml();
892892

893-
return "<a {$hrefHtml}{$wireKeyAttribute} class=\"{$classString}\"{$styleString}>{$iconHtml}{$label}</a>";
893+
return "<a {$hrefHtml}{$wireKeyAttribute} class=\"{$classString}\"{$styleString}>{$iconHtml}<span class=\"fi-link-label\">{$label}</span></a>";
894894
}
895895

896896
$handler = $this->getLivewireClickHandler();
897897

898898
if (blank($handler)) {
899-
return "<span{$wireKeyAttribute} class=\"{$classString}\"{$styleString}>{$label}</span>";
899+
return "<span{$wireKeyAttribute} class=\"{$classString}\"{$styleString}><span class=\"fi-link-label\">{$label}</span></span>";
900900
}
901901

902902
$loadingDelay = config('filament.livewire_loading_delay', 'default');
@@ -921,7 +921,7 @@ protected function toOptimizedLinkHtml(): string
921921
// Match `ComponentAttributeBag::__toString()` attribute escaping (only `"` → `\"`).
922922
$handler = str_replace('"', '\\"', $handler);
923923

924-
return "<button type=\"button\" wire:loading.attr=\"disabled\" wire:click=\"{$handler}\"{$wireKeyAttribute} class=\"{$classString}\"{$styleString}>{$iconHtml}{$loadingHtml}{$label}</button>";
924+
return "<button type=\"button\" wire:loading.attr=\"disabled\" wire:click=\"{$handler}\"{$wireKeyAttribute} class=\"{$classString}\"{$styleString}>{$iconHtml}{$loadingHtml}<span class=\"fi-link-label\">{$label}</span></button>";
925925
}
926926

927927
protected function canRenderOptimizedGrouped(): bool

packages/forms/dist/components/markdown-editor.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/forms/resources/js/components/markdown-editor.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ export default function markdownEditorFormComponent({
102102

103103
state,
104104

105+
wasEditorVisible: false,
106+
107+
resizeObserver: null,
108+
109+
intersectionObserver: null,
110+
105111
async init() {
106112
// If the editor is inside a modal, wait for the modal transition to finish before initializing the editor.
107113
// This is necessary to prevent the editor from being initialized before the modal is fully visible,
@@ -245,9 +251,57 @@ export default function markdownEditorFormComponent({
245251
if (setUpUsing) {
246252
setUpUsing(this)
247253
}
254+
255+
// If the editor initializes while hidden, such as in a collapsed
256+
// section or an inactive tab, CodeMirror renders no lines, and no
257+
// update pass runs when the editor is revealed, so inline image
258+
// previews stay unapplied until the first keystroke. A `refresh()`
259+
// once the editor becomes visible renders it correctly. The
260+
// observers stay connected for the whole lifecycle of the editor
261+
// since it may be hidden and revealed again, potentially receiving
262+
// state changes while hidden, but `refresh()` only runs on the
263+
// hidden-to-visible transition, not on every resize or scroll.
264+
this.wasEditorVisible = this.isEditorVisible()
265+
266+
this.resizeObserver = new ResizeObserver(() =>
267+
this.handleEditorVisibilityChange(),
268+
)
269+
this.resizeObserver.observe(this.$el)
270+
271+
this.intersectionObserver = new IntersectionObserver(() =>
272+
this.handleEditorVisibilityChange(),
273+
)
274+
this.intersectionObserver.observe(this.$el)
275+
},
276+
277+
isEditorVisible() {
278+
// `offsetParent` is `null` when the editor or an ancestor uses
279+
// `display: none`, such as in an inactive tab. A collapsed section
280+
// hides its content with `visibility: hidden` instead, which only
281+
// a computed style check detects.
282+
return (
283+
this.$el.offsetParent !== null &&
284+
getComputedStyle(this.$el).visibility !== 'hidden'
285+
)
286+
},
287+
288+
handleEditorVisibilityChange() {
289+
const isEditorVisible = this.isEditorVisible()
290+
291+
if (isEditorVisible && !this.wasEditorVisible) {
292+
this.editor?.codemirror?.refresh()
293+
}
294+
295+
this.wasEditorVisible = isEditorVisible
248296
},
249297

250298
destroy() {
299+
this.resizeObserver?.disconnect()
300+
this.resizeObserver = null
301+
302+
this.intersectionObserver?.disconnect()
303+
this.intersectionObserver = null
304+
251305
this.editor.cleanup()
252306
this.editor = null
253307
},

packages/forms/resources/js/components/markdown-editor/EasyMDE.js

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* - Removal of line 1 to 15, awaiting https://github.com/Ionaru/easy-markdown-editor/pull/263
55
* - Added `moveToNextField()` and `moveToPreviousField()` functions, and changed `Tab` and `Shift-Tab` key bindings to only indent the content when there is a selection in the editor. See https://github.com/filamentphp/filament/pull/16144.
66
* - Wrapped the indent/outdent operations in `toggleCodeBlock()` in `cm.operation()` so they group into a single CodeMirror undo step. See https://github.com/filamentphp/filament/pull/19890.
7+
* - Changed `minHeight` and `maxHeight` to apply independently when both options are set. See https://github.com/Ionaru/easy-markdown-editor/issues/413.
78
*/
89

910
// Some variables
@@ -441,11 +442,18 @@ function toggleFullScreen(editor) {
441442

442443
// Remove or set maxHeight
443444
if (typeof editor.options.maxHeight !== 'undefined') {
445+
var heightProperty = editor.hasExplicitMinHeight
446+
? 'max-height'
447+
: 'height'
448+
444449
if (cm.getOption('fullScreen')) {
445-
cm.getScrollerElement().style.removeProperty('height')
446-
sidebyside.style.removeProperty('height')
450+
cm.getScrollerElement().style.removeProperty(heightProperty)
451+
sidebyside.style.removeProperty(heightProperty)
447452
} else {
448-
cm.getScrollerElement().style.height = editor.options.maxHeight
453+
cm.getScrollerElement().style.setProperty(
454+
heightProperty,
455+
editor.options.maxHeight,
456+
)
449457
editor.setPreviewMaxHeight()
450458
}
451459
}
@@ -1924,6 +1932,8 @@ function EasyMDE(options) {
19241932
// Handle options parameter
19251933
options = options || {}
19261934

1935+
this.hasExplicitMinHeight = Boolean(options.minHeight)
1936+
19271937
// Used later to refer to it"s parent
19281938
options.parent = this
19291939

@@ -2049,8 +2059,12 @@ function EasyMDE(options) {
20492059

20502060
options.direction = options.direction || 'ltr'
20512061

2052-
if (typeof options.maxHeight !== 'undefined') {
2053-
// Min and max height are equal if maxHeight is set
2062+
if (
2063+
typeof options.maxHeight !== 'undefined' &&
2064+
!this.hasExplicitMinHeight
2065+
) {
2066+
// Preserve the fixed-height behavior introduced in
2067+
// https://github.com/Ionaru/easy-markdown-editor/pull/222
20542068
options.minHeight = options.maxHeight
20552069
} else {
20562070
options.minHeight = options.minHeight || '300px'
@@ -2521,7 +2535,12 @@ EasyMDE.prototype.render = function (el) {
25212535
this.codemirror.getScrollerElement().style.minHeight = options.minHeight
25222536

25232537
if (typeof options.maxHeight !== 'undefined') {
2524-
this.codemirror.getScrollerElement().style.height = options.maxHeight
2538+
this.codemirror
2539+
.getScrollerElement()
2540+
.style.setProperty(
2541+
this.hasExplicitMinHeight ? 'max-height' : 'height',
2542+
options.maxHeight,
2543+
)
25252544
}
25262545

25272546
if (options.forceSync === true) {
@@ -3004,18 +3023,22 @@ EasyMDE.prototype.setPreviewMaxHeight = function () {
30043023
var cm = this.codemirror
30053024
var wrapper = cm.getWrapperElement()
30063025
var preview = wrapper.nextSibling
3007-
3008-
// Calc preview max height
3009-
var paddingTop = parseInt(window.getComputedStyle(wrapper).paddingTop)
3010-
var borderTopWidth = parseInt(
3011-
window.getComputedStyle(wrapper).borderTopWidth,
3026+
var wrapperStyle = window.getComputedStyle(wrapper)
3027+
3028+
preview.style.setProperty(
3029+
this.hasExplicitMinHeight ? 'max-height' : 'height',
3030+
'calc(' +
3031+
this.options.maxHeight +
3032+
' + ' +
3033+
wrapperStyle.paddingTop +
3034+
' + ' +
3035+
wrapperStyle.paddingBottom +
3036+
' + ' +
3037+
wrapperStyle.borderTopWidth +
3038+
' + ' +
3039+
wrapperStyle.borderBottomWidth +
3040+
')',
30123041
)
3013-
var optionsMaxHeight = parseInt(this.options.maxHeight)
3014-
var wrapperMaxHeight =
3015-
optionsMaxHeight + paddingTop * 2 + borderTopWidth * 2
3016-
var previewMaxHeight = wrapperMaxHeight.toString() + 'px'
3017-
3018-
preview.style.height = previewMaxHeight
30193042
}
30203043

30213044
EasyMDE.prototype.createSideBySide = function () {

packages/forms/src/Components/MorphToSelect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function setUp(): void
135135
->preload($component->isPreloaded())
136136
->when(
137137
$component->isLive(),
138-
fn (Select $component) => $component->live(onBlur: $this->isLiveOnBlur()),
138+
fn (Select $select) => $select->live(onBlur: $component->isLiveOnBlur()),
139139
)
140140
->afterStateUpdated(function () use ($component): void {
141141
$component->callAfterStateUpdatedForChildComponent();

packages/panels/dist/theme.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/panels/src/Commands/MakePageCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ class_exists($relationshipInstance->getRelated()::class) &&
669669
MorphToMany::class => 'MorphToMany',
670670
'other' => 'Other',
671671
],
672+
default: $this->input->isInteractive() ? null : 'other',
672673
);
673674

674675
if ($relationshipType === 'other') {

0 commit comments

Comments
 (0)