Skip to content

Commit 20a40ca

Browse files
committed
feat(select): add helper and error text to core
1 parent a70f825 commit 20a40ca

File tree

2 files changed

+16
-41
lines changed

2 files changed

+16
-41
lines changed

core/src/components/select/select.tsx

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export class Select implements ComponentInterface {
6060
private inheritedAttributes: Attributes = {};
6161
private nativeWrapperEl: HTMLElement | undefined;
6262
private notchSpacerEl: HTMLElement | undefined;
63-
6463

6564
private notchController?: NotchController;
6665

@@ -109,7 +108,7 @@ export class Select implements ComponentInterface {
109108
/**
110109
* Text that is placed under the select and displayed when an error is detected.
111110
*/
112-
@Prop() errorText?: string;
111+
@Prop() errorText?: string;
113112

114113
/**
115114
* The interface the select should use: `action-sheet`, `popover`, `alert`, or `modal`.
@@ -742,21 +741,6 @@ export class Select implements ComponentInterface {
742741
</div>,
743742
];
744743
}
745-
746-
private getHintTextID(): string | undefined {
747-
const { el, helperText, errorText, helperTextId, errorTextId } = this;
748-
749-
if (el.classList.contains('ion-touched') && el.classList.contains('ion-invalid') && errorText) {
750-
return errorTextId;
751-
}
752-
753-
if (helperText) {
754-
return helperTextId;
755-
}
756-
757-
return undefined;
758-
}
759-
760744
private get childOpts() {
761745
return Array.from(this.el.querySelectorAll('ion-select-option'));
762746
}
@@ -856,10 +840,10 @@ export class Select implements ComponentInterface {
856840
};
857841

858842
/**
859-
* Responsible for rendering helper text and
860-
* error text. This element should only
861-
* be rendered if hint text is set.
862-
*/
843+
* Responsible for rendering helper text and
844+
* error text. This element should only
845+
* be rendered if hint text is set.
846+
*/
863847
private renderBottomContent() {
864848
const { helperText, errorText } = this;
865849

@@ -868,18 +852,11 @@ export class Select implements ComponentInterface {
868852
* be treated as not having helper/error text.
869853
*/
870854
const hasHintText = !!helperText || !!errorText;
871-
console.log(`HelperText: ${helperText}`);
872-
console.log(`errorText: ${errorText}`);
873855
if (!hasHintText) {
874-
console.log("No text");
875856
return;
876857
}
877858

878-
return (
879-
<div class="input-bottom">
880-
{this.renderHintText()}
881-
</div>
882-
);
859+
return <div class="input-bottom">{this.renderHintText()}</div>;
883860
}
884861

885862
private renderLabel() {

core/src/components/select/test/bottom-content/index.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@
5050

5151
<ion-content id="content" class="ion-padding">
5252
<div class="grid">
53-
5453
<div class="grid-item">
5554
<h2>Select with Helper text</h2>
56-
<ion-select class="ion-touched ion-valid"
57-
helper-text="Select a fruit"
58-
value="apple">
55+
<ion-select class="ion-touched ion-valid" helper-text="Select a fruit" value="apple">
5956
<div slot="label">Favorite Fruit</div>
6057
<ion-select-option value="apple">Apple</ion-select-option>
6158
<ion-select-option value="bananna">Bananna</ion-select-option>
@@ -64,8 +61,7 @@ <h2>Select with Helper text</h2>
6461

6562
<div class="grid-item">
6663
<h2>Select with Error text</h2>
67-
<ion-select class="ion-touched ion-invalid"
68-
error-text="No fruit selected">
64+
<ion-select class="ion-touched ion-invalid" error-text="No fruit selected">
6965
<div slot="label">Favorite Fruit</div>
7066
<ion-select-option value="apple">Apple</ion-select-option>
7167
<ion-select-option value="bananna">Bananna</ion-select-option>
@@ -74,8 +70,12 @@ <h2>Select with Error text</h2>
7470

7571
<div class="grid-item">
7672
<h2>Select with Helper and error text| Valid</h2>
77-
<ion-select class="ion-touched ion-valid" helper-text="Select a fruit"
78-
error-text="No fruit selected" value="apple">
73+
<ion-select
74+
class="ion-touched ion-valid"
75+
helper-text="Select a fruit"
76+
error-text="No fruit selected"
77+
value="apple"
78+
>
7979
<div slot="label">Favorite Fruit</div>
8080
<ion-select-option value="apple">Apple</ion-select-option>
8181
<ion-select-option value="bananna">Bananna</ion-select-option>
@@ -84,17 +84,15 @@ <h2>Select with Helper and error text| Valid</h2>
8484

8585
<div class="grid-item">
8686
<h2>Select with no helper or error text</h2>
87-
<ion-select class="ion-touched ion-valid"
88-
value="bananna">
87+
<ion-select class="ion-touched ion-valid" value="bananna">
8988
<div slot="label">Favorite Fruit</div>
9089
<ion-select-option value="apple">Apple</ion-select-option>
9190
<ion-select-option value="bananna">Bananna</ion-select-option>
9291
</ion-select>
9392
</div>
9493
</div>
9594

96-
<script>
97-
</script>
95+
<script></script>
9896
</ion-content>
9997
</ion-app>
10098
</body>

0 commit comments

Comments
 (0)