Skip to content

Commit 2223cdb

Browse files
authored
Merge pull request #2544 from intersective/2.4.y/CORE-8012/slider-broken-null
[CORE-8012] 2.4.y/slider broken null
2 parents 767be99 + 03b7b1b commit 2223cdb

22 files changed

+896
-144
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Toggle Label Directive
2+
3+
This directive was created to accommodate the use of innerHTML in ion-checkbox and ion-radio labels. It provides a solution for dynamically toggling label content and handling HTML content within Ionic form controls where standard label binding may not be sufficient.
4+
5+
## Problem Statement
6+
The issue arises when clicking on the content within the innerHTML title text of ion-checkbox or ion-radio components. The expected behavior is that clicking the label should toggle the checkbox or radio button state. However, due to the way innerHTML is handled, the click event does not propagate correctly to the underlying input element, preventing the toggle action from occurring. This can lead to a confusing user experience where the label appears clickable but does not perform the intended function.
7+
8+
### Comparison of Implementations
9+
10+
#### Default Recommended Code Implementation
11+
```html
12+
<ion-checkbox [(ngModel)]="isChecked" (click)="toggleCheckbox()">
13+
<ion-label>Toggle me</ion-label>
14+
</ion-checkbox>
15+
```
16+
In this implementation, clicking the label correctly toggles the checkbox state because the label is directly associated with the checkbox input.
17+
18+
#### Implementation with innerHTML
19+
```html
20+
<ion-checkbox [(ngModel)]="isChecked">
21+
<ion-label [innerHTML]="dynamicLabel" (click)="toggleCheckbox()"></ion-label>
22+
</ion-checkbox>
23+
```
24+
In this case, while the label appears clickable, the click event does not propagate to the checkbox input, resulting in no toggle action occurring when the label is clicked.
25+
26+
This comparison highlights the importance of using standard label binding to ensure proper functionality in Ionic form controls.
27+
28+
## Purpose
29+
- Enable dynamic label content for Ionic checkbox and radio components
30+
- Support HTML content rendering within form control labels
31+
- Provide consistent label behavior across different form input types
32+
33+
## Usage
34+
Apply this directive to elements that need dynamic label toggling functionality, particularly useful with Ionic form controls that require innerHTML support.
35+
36+
## Note
37+
This directive addresses limitations in standard Ionic label handling where innerHTML content needs to be dynamically managed for checkbox and radio controls.

docs/docs.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ This is practera documentation with more informations.
77

88
### Components
99
- [Chat Room Component](./components/chatRoomComponent.md)
10-
- [Chat List Component](./components/chatListComponent.md)
10+
- [Chat List Component](./components/chatListComponent.md)
11+
12+
### Directives
13+
- [Toggle Label Directive](./directives/toggleLabelDirective.md)

package-lock.json

Lines changed: 0 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/v3/src/app/components/assessment/assessment.component.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,21 @@
203203
[@tickAnimation]="failed()[question.id] ? 'visible' : 'hidden'"></ion-icon>
204204
</div>
205205

206-
<ion-item *ngIf="!doAssessment && (
207-
(!question.reviewerOnly && utils.isEmpty(submission?.answers[question.id]?.answer)) ||
208-
(question.reviewerOnly && !review?.answers[question.id] && !isPendingReview)
209-
)"
210-
class="no-answers item-bottom-border"
211-
lines="none">
212-
<ion-icon slot="start"
213-
color="orange"
214-
name="information-circle-outline"
215-
class="ion-margin-end"></ion-icon>
216-
<ion-label size="small"
217-
i18n>No answer for this question.</ion-label>
218-
</ion-item>
206+
<ng-container *ngIf="question.type !== 'slider'">
207+
<ion-item *ngIf="!doAssessment && (
208+
(!question.reviewerOnly && utils.isEmpty(submission?.answers[question.id]?.answer)) ||
209+
(question.reviewerOnly && !review?.answers[question.id] && !isPendingReview)
210+
)"
211+
class="no-answers item-bottom-border"
212+
lines="none">
213+
<ion-icon slot="start"
214+
color="orange"
215+
name="information-circle-outline"
216+
class="ion-margin-end"></ion-icon>
217+
<ion-label size="small"
218+
i18n>No answer for this question.</ion-label>
219+
</ion-item>
220+
</ng-container>
219221

220222
<app-text *ngSwitchCase="'text'"
221223
#questionField
@@ -416,4 +418,4 @@
416418
<ng-template #blocked>
417419
<app-bottom-action-bar buttonType="blocked-role"></app-bottom-action-bar>
418420
</ng-template>
419-
</ng-container>
421+
</ng-container>

0 commit comments

Comments
 (0)