Skip to content

Commit

Permalink
[FIX] added requested third disabled state.
Browse files Browse the repository at this point in the history
  • Loading branch information
pouyababaie committed Mar 24, 2024
1 parent f2741bb commit f332e2d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 12 deletions.
54 changes: 43 additions & 11 deletions src/app/components/splitbutton/splitbutton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type SplitButtonIconPosition = 'left' | 'right';
[iconPos]="iconPos"
[label]="label"
(click)="onDefaultButtonClick($event)"
[disabled]="disabled"
[disabled]="buttonDisabled"
[attr.tabindex]="tabindex"
[attr.aria-label]="buttonProps?.['aria-label']"
></button>
Expand Down Expand Up @@ -126,16 +126,7 @@ export class SplitButton {
* When present, it specifies that the element should be disabled.
* @group Props
*/
@Input() disabled: boolean | undefined;
/**
* When present, it specifies that the element should be disabled.
* @group Props
*/
@Input() menuButtonDisabled: boolean | undefined;
/**
* Index of the element in tabbing order.
* @group Prop
*/

@Input() tabindex: number | undefined;
/**
* Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).
Expand Down Expand Up @@ -181,6 +172,47 @@ export class SplitButton {
* @param {MouseEvent} event - Mouse event.
* @group Emits
*/
private _disabled: boolean | undefined;
@Input() set disabled(v: boolean | undefined) {
this._disabled = v;
this._buttonDisabled = v;
this.menuButtonDisabled = v;
}
public get disabled(): boolean | undefined {
return this._disabled;
}
/**
* Index of the element in tabbing order.
* @group Prop
*/

/**
* When present, it specifies that the menu button element should be disabled.
* @group Props
*/
private _menuButtonDisabled: boolean | undefined;
@Input('menuButtonDisabled') set menuButtonDisabled(v: boolean | undefined) {
if (this.disabled) {
this._menuButtonDisabled = this.disabled;
} else this._menuButtonDisabled = v;
}
public get menuButtonDisabled(): boolean | undefined {
return this._menuButtonDisabled;
}
/**
* When present, it specifies that the button element should be disabled.
* @group Props
*/
private _buttonDisabled: boolean | undefined;
@Input() set buttonDisabled(v: boolean | undefined) {
if (this.disabled) {
this.buttonDisabled = this.disabled;
} else this._buttonDisabled = v;
}
public get buttonDisabled(): boolean {
return this._buttonDisabled;
}

@Output() onDropdownClick: EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();

@ViewChild('container') containerViewChild: ElementRef | undefined;
Expand Down
12 changes: 11 additions & 1 deletion src/app/showcase/doc/splitbutton/disableddoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Code } from '../../domain/code';
template: `
<app-docsectiontext>
<p>When <i>disabled</i> is present, the element cannot be edited and focused.</p>
<p>You can now use <i>menuButtonDisabled</i> to disable menu icon button.</p>
<p>You can now use <i>menuButtonDisabled</i> and <i>buttonDisabled</i> to disable menu icon button and the main button.</p>
<p>also , you can set the default <i>disabled</i> attribute to true , so you can disable both buttons.</p>
</app-docsectiontext>
<div class="card flex justify-content-center">
<p-toast></p-toast>
Expand All @@ -17,6 +18,10 @@ import { Code } from '../../domain/code';
<p-toast></p-toast>
<p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" [menuButtonDisabled]="true"></p-splitButton>
</div>
<div class="card flex justify-content-center">
<p-toast></p-toast>
<p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" [buttonDisabled]="true"></p-splitButton>
</div>
<app-code [code]="code" selector="split-button-disabled-demo"></app-code>
`,
providers: [MessageService]
Expand Down Expand Up @@ -72,6 +77,11 @@ export class DisabledDoc {
<p-toast></p-toast>
<p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" [menuButtonDisabled]="true"></p-splitButton>
</div>
<div class="card flex justify-content-center">
<p-toast></p-toast>
<p-splitButton label="Save" icon="pi pi-plus" (onClick)="save('info')" [model]="items" [buttonDisabled]="true"></p-splitButton>
</div>
`,

Expand Down

0 comments on commit f332e2d

Please sign in to comment.