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 <lnt@umbraco.dk>
This commit is contained in:
NguyenThuyLan
2025-11-05 19:12:04 +07:00
committed by GitHub
parent 297c5d3824
commit 72d7ed438f
5 changed files with 10 additions and 6 deletions

View File

@@ -198,6 +198,9 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
@state()
private _isReadOnly: boolean = false;
@state()
private _limitMax?: number;
constructor() {
super();
@@ -294,6 +297,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
}
async #setupRangeValidation(rangeLimit: UmbNumberRangeValueType | undefined) {
this._limitMax = rangeLimit?.max;
if (this.#rangeUnderflowValidator) {
this.removeValidator(this.#rangeUnderflowValidator);
this.#rangeUnderflowValidator = undefined;
@@ -408,6 +412,7 @@ export class UmbBlockGridEntriesElement extends UmbFormControlMixin(UmbLitElemen
}
#renderCreateButtonGroup() {
if (this._limitMax === 1 && this._layoutEntries.length > 0) return nothing;
if (this._areaKey === null || this._layoutEntries.length === 0) {
return html` <uui-button-group id="createButton">
${this.#renderCreateButton()} ${this.#renderPasteButton()}

View File

@@ -394,11 +394,8 @@ export class UmbPropertyEditorUIBlockListElement
}
#renderCreateButtonGroup() {
if (this.readonly && this._layouts.length > 0) {
return nothing;
} else {
return html`<uui-button-group>${this.#renderCreateButton()}${this.#renderPasteButton()}</uui-button-group>`;
}
if (this._layouts.length > 0 && (this._limitMax === 1 || this.readonly)) return nothing;
return html`<uui-button-group>${this.#renderCreateButton()}${this.#renderPasteButton()}</uui-button-group>`;
}
#renderInlineCreateButton(index: number) {

View File

@@ -221,6 +221,7 @@ export class UmbInputMultipleTextStringElement extends UmbFormControlMixin<undef
#renderAddButton() {
if (this.disabled || this.readonly) return nothing;
if (this.max === 1 && this._items.length > 0) return nothing;
return html`
<uui-button
color="default"

View File

@@ -214,7 +214,7 @@ export class UmbInputDocumentElement extends UmbFormControlMixin<string | undefi
}
#renderAddButton() {
if (this.selection.length >= this.max) return nothing;
if (this.selection.length > 0 && this.max === 1) return nothing;
if (this.readonly && this.selection.length > 0) {
return nothing;
} else {

View File

@@ -388,6 +388,7 @@ export class UmbInputRichMediaElement extends UmbFormControlMixin<
#renderAddButton() {
if (this.readonly) return nothing;
if (this.max === 1 && this._cards.length > 0) return nothing;
return html`
<uui-button
id="btn-add"