0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 01:22:07 +01:00

fix: InlinePanel - take 1st child when configuring up and down js events

Issue was appearing when there was nested inline panels.
currentChild. find would match the parent up/down button
but also all the ones of the nested inline panels
Fixes #5919
This commit is contained in:
Adrien Hamraoui 2024-02-02 10:24:26 +01:00 committed by LB (Ben Johnston)
parent bfa29201c3
commit 58ebfe1fb1
4 changed files with 15 additions and 4 deletions

View File

@ -12,6 +12,7 @@ Changelog
* Fix: Fix typo in `__str__` for MySQL search index (Jake Howard)
* Fix: Ensure that unit tests correctly check for migrations in all core Wagtail apps (Matt Westcott)
* Fix: Correctly handle `date` objects on `human_readable_date` template tag (Jhonatan Lopes)
* Fix: Ensure re-ordering buttons work correctly when using a nested InlinePanel (Adrien Hamraoui)
* Docs: Add contributing development documentation on how to work with a fork of Wagtail (Nix Asteri, Dan Braghis)
* Docs: Make sure the settings panel is listed in tabbed interface examples (Tibor Leupold)
* Docs: Update multiple pages in the reference sections and multiple page names to their US spelling instead of UK spelling (Victoria Poromon)

View File

@ -798,6 +798,7 @@
* Hossein
* Andre Delorme
* arshyia3000
* Adrien Hamraoui
## Translators

View File

@ -52,8 +52,10 @@ export class InlinePanel extends ExpandingFormset {
const childId = 'inline_child_' + prefix;
const deleteInputId = 'id_' + prefix + '-DELETE';
const currentChild = $('#' + childId);
const $up = currentChild.find('[data-inline-panel-child-move-up]');
const $down = currentChild.find('[data-inline-panel-child-move-down]');
const $up = currentChild.find('[data-inline-panel-child-move-up]:first ');
const $down = currentChild.find(
'[data-inline-panel-child-move-down]:first ',
);
$('#' + deleteInputId + '-button').on('click', () => {
/* set 'deleted' form field to true */
@ -148,8 +150,14 @@ export class InlinePanel extends ExpandingFormset {
forms.each(function updateButtonStates(i) {
const isFirst = i === 0;
const isLast = i === forms.length - 1;
$('[data-inline-panel-child-move-up]', this).prop('disabled', isFirst);
$('[data-inline-panel-child-move-down]', this).prop('disabled', isLast);
$('[data-inline-panel-child-move-up]:first', this).prop(
'disabled',
isFirst,
);
$('[data-inline-panel-child-move-down]:first', this).prop(
'disabled',
isLast,
);
});
}
}

View File

@ -25,6 +25,7 @@ depth: 1
* Fix typo in `__str__` for MySQL search index (Jake Howard)
* Ensure that unit tests correctly check for migrations in all core Wagtail apps (Matt Westcott)
* Correctly handle `date` objects on `human_readable_date` template tag (Jhonatan Lopes)
* Ensure re-ordering buttons work correctly when using a nested InlinePanel (Adrien Hamraoui)
### Documentation