Skip to content

Commit 72d7ed4

Browse files
Property Editors: Hide "add button" when maximum configuration is 1 (fixes #20407) (#20738)
Hide add button when max 1 Co-authored-by: Lan Nguyen Thuy <[email protected]>
1 parent 297c5d3 commit 72d7ed4

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

src/Umbraco.Web.UI.Client/src/packages/block/block-grid/components/block-grid-entries/block-grid-entries.element.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
198198
@state()
199199
private _isReadOnly: boolean = false;
200200

201+
@state()
202+
private _limitMax?: number;
203+
201204
constructor() {
202205
super();
203206

@@ -294,6 +297,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
294297
}
295298

296299
async #setupRangeValidation(rangeLimit: UmbNumberRangeValueType | undefined) {
300+
this._limitMax = rangeLimit?.max;
297301
if (this.#rangeUnderflowValidator) {
298302
this.removeValidator(this.#rangeUnderflowValidator);
299303
this.#rangeUnderflowValidator = undefined;
@@ -408,6 +412,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
408412
}
409413

410414
#renderCreateButtonGroup() {
415+
if (this._limitMax === 1 && this._layoutEntries.length > 0) return nothing;
411416
if (this._areaKey === null || this._layoutEntries.length === 0) {
412417
return html` <uui-button-group id="createButton">
413418
${this.#renderCreateButton()} ${this.#renderPasteButton()}

src/Umbraco.Web.UI.Client/src/packages/block/block-list/property-editors/block-list-editor/property-editor-ui-block-list.element.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,8 @@ export class UmbPropertyEditorUIBlockListElement
394394
}
395395

396396
#renderCreateButtonGroup() {
397-
if (this.readonly && this._layouts.length > 0) {
398-
return nothing;
399-
} else {
400-
return html`<uui-button-group>${this.#renderCreateButton()}${this.#renderPasteButton()}</uui-button-group>`;
401-
}
397+
if (this._layouts.length > 0 && (this._limitMax === 1 || this.readonly)) return nothing;
398+
return html`<uui-button-group>${this.#renderCreateButton()}${this.#renderPasteButton()}</uui-button-group>`;
402399
}
403400

404401
#renderInlineCreateButton(index: number) {

src/Umbraco.Web.UI.Client/src/packages/core/components/multiple-text-string-input/input-multiple-text-string.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export class UmbInputMultipleTextStringElement extends UmbFormControlMixin<undef
221221

222222
#renderAddButton() {
223223
if (this.disabled || this.readonly) return nothing;
224+
if (this.max === 1 && this._items.length > 0) return nothing;
224225
return html`
225226
<uui-button
226227
color="default"

src/Umbraco.Web.UI.Client/src/packages/documents/documents/components/input-document/input-document.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export class UmbInputDocumentElement extends UmbFormControlMixin<string | undefi
214214
}
215215

216216
#renderAddButton() {
217-
if (this.selection.length >= this.max) return nothing;
217+
if (this.selection.length > 0 && this.max === 1) return nothing;
218218
if (this.readonly && this.selection.length > 0) {
219219
return nothing;
220220
} else {

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-rich-media/input-rich-media.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ export class UmbInputRichMediaElement extends UmbFormControlMixin<
388388

389389
#renderAddButton() {
390390
if (this.readonly) return nothing;
391+
if (this.max === 1 && this._cards.length > 0) return nothing;
391392
return html`
392393
<uui-button
393394
id="btn-add"

0 commit comments

Comments
 (0)