Skip to content

Commit

Permalink
Merge branch '5.x' into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Nov 28, 2024
2 parents 4df2822 + 4ac4d02 commit bcb8965
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

## Unreleased

- Fixed an error that could occur when duplicating an element with an Assets field that had a dynamic subpath. ([#16214](https://github.com/craftcms/cms/issues/16214))
- Fixed a bug where element slideouts had Save buttons even if the user didn’t have permission to save the element. ([#16205](https://github.com/craftcms/cms/pull/16205))
- Fixed a bug where pagination wasn’t working properly on the Entry Types index page when searching. ([#16204](https://github.com/craftcms/cms/issues/16204))
- Fixed an error that could occur when saving an element with an invalid Link field value. ([#16212](https://github.com/craftcms/cms/issues/16212))
- Fixed a bug where sortable checkbox selects were displaying menu buttons even when only one option was selected. ([#16213](https://github.com/craftcms/cms/issues/16213))

## 5.5.3 - 2024-11-22

Expand Down
3 changes: 3 additions & 0 deletions src/fields/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,9 @@ private function _findFolder(string $sourceKey, ?string $subpath, ?ElementInterf
if ($isDynamic) {
// Prepare the path by parsing tokens and normalizing slashes.
try {
if ($element?->duplicateOf) {
$element = $element->duplicateOf;
}
$renderedSubpath = Craft::$app->getView()->renderObjectTemplate($subpath, $element);
} catch (InvalidConfigException|RuntimeError $e) {
throw new InvalidSubpathException($subpath, null, 0, $e);
Expand Down
9 changes: 7 additions & 2 deletions src/fields/linktypes/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ protected function inputAttributes(): array

public function validateValue(string $value, ?string &$error = null): bool
{
// Leveraging Uri package to convert domains to punycode
return parent::validateValue(Uri::new($value), $error);
try {
// Leveraging Uri package to convert domains to punycode
$value = Uri::new($value);
return parent::validateValue($value, $error);
} catch (\Exception $e) {
return false;
}
}

protected function pattern(): string
Expand Down
4 changes: 4 additions & 0 deletions src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/web/assets/cp/src/js/SortableCheckboxSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,26 @@ Craft.SortableCheckboxSelect.Item = Garnish.Base.extend({
}
});

const allCheckedSiblings = this.getAllCheckedSiblings();
// if there are no other checked siblings, hide current item's action menu btn
if (allCheckedSiblings.length == 0) {
this.$actionMenuBtn.hide();
} else if (allCheckedSiblings.length == 1) {
// if there's only one other checked sibling,
// we need to show that sibling's action menu btn as it would have been hidden so far
$(allCheckedSiblings[0]).find('.btn.action-btn').show();
}

this.$item.trigger('checked');
},

onUncheck: function () {
const allCheckedSiblings = this.getAllCheckedSiblings();
// if there's only one other checked sibling, hide that sibling's action menu btn
if (allCheckedSiblings.length == 1) {
$(allCheckedSiblings[0]).find('.btn.action-btn').hide();
}

this.$moveHandle?.addClass('disabled');
this.$actionMenuBtn?.remove();
this.$actionMenu?.remove();
Expand All @@ -149,6 +165,12 @@ Craft.SortableCheckboxSelect.Item = Garnish.Base.extend({
return $item.length ? $item : null;
},

getAllCheckedSiblings: function () {
return this.$item.siblings(
'.checkbox-select-item:not(.all):has(input[type=checkbox]:checked)'
);
},

moveUp: function () {
const $prev = this.getPrevCheckedItem();
if ($prev) {
Expand Down

0 comments on commit bcb8965

Please sign in to comment.