Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TriStateCheckbox: Fix problem when click on label and updated docs #13977

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
*/
@Output() activeIndexChange: EventEmitter<number | number[]> = new EventEmitter<number | number[]>();

@ContentChildren(AccordionTab, {descendants: true}) tabList: QueryList<AccordionTab> | undefined;
@ContentChildren(AccordionTab, { descendants: true }) tabList: QueryList<AccordionTab> | undefined;

tabListSubscription: Subscription | null = null;

Expand Down
5 changes: 5 additions & 0 deletions src/app/components/tristatecheckbox/tristatecheckbox.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@layer primeng {
.p-tristatecheckbox-label {
cursor: pointer;
}
}
7 changes: 4 additions & 3 deletions src/app/components/tristatecheckbox/tristatecheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const TRISTATECHECKBOX_VALUE_ACCESSOR: any = {
@Component({
selector: 'p-triStateCheckbox',
template: `
<div [ngStyle]="style" [ngClass]="{ 'p-checkbox p-component': true, 'p-checkbox-disabled': disabled, 'p-checkbox-focused': focused }" [class]="styleClass">
<div [ngStyle]="style" [ngClass]="{ 'p-checkbox p-component': true, 'p-checkbox-disabled': disabled, 'p-checkbox-focused': focused }" [class]="styleClass" (click)="onClick($event, input)">
<div class="p-hidden-accessible">
<input
#input
Expand All @@ -37,7 +37,7 @@ export const TRISTATECHECKBOX_VALUE_ACCESSOR: any = {
inputmode="none"
/>
</div>
<div class="p-checkbox-box" (click)="onClick($event, input)" role="checkbox" [attr.aria-checked]="value === true" [ngClass]="{ 'p-highlight': value != null, 'p-disabled': disabled, 'p-focus': focused }">
<div class="p-checkbox-box" role="checkbox" [attr.aria-checked]="value === true" [ngClass]="{ 'p-highlight': value != null, 'p-disabled': disabled, 'p-focus': focused }">
<ng-container *ngIf="value === true">
<span *ngIf="checkboxTrueIcon" [ngClass]="checkboxTrueIcon" class="p-checkbox-icon"></span>
<ng-container *ngIf="!checkboxTrueIcon">
Expand All @@ -58,11 +58,12 @@ export const TRISTATECHECKBOX_VALUE_ACCESSOR: any = {
</ng-container>
</div>
</div>
<label class="p-checkbox-label" (click)="onClick($event, input)" [ngClass]="{ 'p-checkbox-label-active': value != null, 'p-disabled': disabled, 'p-checkbox-label-focus': focused }" *ngIf="label" [attr.for]="inputId">{{ label }}</label>
<label class="p-tristatecheckbox-label" [ngClass]="{ 'p-checkbox-label-active': value != null, 'p-disabled': disabled, 'p-checkbox-label-focus': focused }" *ngIf="label" [attr.for]="inputId">{{ label }}</label>
`,
providers: [TRISTATECHECKBOX_VALUE_ACCESSOR],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
styleUrls: ['./tristatecheckbox.css'],
host: {
class: 'p-element'
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/showcase/doc/tristatecheckbox/basicdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Code } from '../../domain/code';
</app-docsectiontext>
<div class="card flex flex-column gap-3 align-items-center">
<p-triStateCheckbox [(ngModel)]="value" inputId="tricheckbox"></p-triStateCheckbox>
<label for="tricheckbox">{{ value === null ? 'null' : value }}</label>
<label class="p-tristatecheckbox-label" for="tricheckbox">{{ value === null ? 'null' : value }}</label>
</div>
<app-code [code]="code" selector="tri-state-checkbox-basic-demo"></app-code>
</section>`
Expand All @@ -23,12 +23,12 @@ export class BasicDoc {

code: Code = {
basic: `
<p-triStateCheckbox [(ngModel)]="value" inputId="tricheckbox"></p-triStateCheckbox>`,
<p-triStateCheckbox class="p-tristatecheckbox-label" [(ngModel)]="value" inputId="tricheckbox"></p-triStateCheckbox>`,

html: `
<div class="card flex flex-column gap-3 align-items-center">
<p-triStateCheckbox [(ngModel)]="value" inputId="tricheckbox"></p-triStateCheckbox>
<label for="tricheckbox">{{ value === null ? 'null' : value }}</label>
<label class="p-tristatecheckbox-label" for="tricheckbox">{{ value === null ? 'null' : value }}</label>
</div>`,

typescript: `
Expand Down
6 changes: 3 additions & 3 deletions src/app/showcase/doc/tristatecheckbox/reactiveformsdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Code } from '../../domain/code';
<div class="card flex justify-content-center">
<form [formGroup]="formGroup" class="flex flex-column align-items-center gap-3">
<p-triStateCheckbox formControlName="checked" inputId="checked"></p-triStateCheckbox>
<label for="checked">{{ formGroup.value.checked === null ? 'null' : formGroup.value.checked }}</label>
<label class="p-tristatecheckbox-label" for="checked">{{ formGroup.value.checked === null ? 'null' : formGroup.value.checked }}</label>
</form>
</div>
<app-code [code]="code" selector="tri-state-checkbox-reactive-forms-demo"></app-code>
Expand All @@ -34,14 +34,14 @@ export class ReactiveFormsDoc implements OnInit {
basic: `
<form [formGroup]="formGroup" class="flex flex-column align-items-center gap-3">
<p-triStateCheckbox formControlName="checked" inputId="checked"></p-triStateCheckbox>
<label for="checked">{{ formGroup.value.checked === null ? 'null' : formGroup.value.checked }}</label>
<label class="p-tristatecheckbox-label" for="checked">{{ formGroup.value.checked === null ? 'null' : formGroup.value.checked }}</label>
</form>`,

html: `
<div class="card flex justify-content-center">
<form [formGroup]="formGroup" class="flex flex-column align-items-center gap-3">
<p-triStateCheckbox formControlName="checked" inputId="checked"></p-triStateCheckbox>
<label for="checked">{{ formGroup.value.checked === null ? 'null' : formGroup.value.checked }}</label>
<label class="p-tristatecheckbox-label" for="checked">{{ formGroup.value.checked === null ? 'null' : formGroup.value.checked }}</label>
</form>
</div>`,

Expand Down
Loading