Skip to content

Commit 50b0c6f

Browse files
authored
fix(alert): accepts any value (#16476)
fixes #16170
1 parent 69f63b3 commit 50b0c6f

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

core/src/components/alert/alert-interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface AlertInput {
2323
type?: TextFieldTypes | 'checkbox' | 'radio';
2424
name?: string;
2525
placeholder?: string;
26-
value?: string;
26+
value?: any;
2727
label?: string;
2828
checked?: boolean;
2929
disabled?: boolean;

core/src/components/alert/alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class Alert implements ComponentInterface, OverlayInterface {
156156
type: i.type || 'text',
157157
name: i.name || `${index}`,
158158
placeholder: i.placeholder || '',
159-
value: i.value || '',
159+
value: i.value,
160160
label: i.label,
161161
checked: !!i.checked,
162162
disabled: !!i.disabled,

core/src/components/radio/radio.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class Radio implements ComponentInterface {
105105
}
106106

107107
componentWillLoad() {
108-
if (this.value == null) {
108+
if (this.value === undefined) {
109109
this.value = this.inputId;
110110
}
111111
this.emitStyle();
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!DOCTYPE html>
2+
<html dir="ltr">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Select - Basic</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
8+
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
9+
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
10+
<script src="../../../../../dist/ionic.js"></script>
11+
</head>
12+
13+
<body>
14+
<ion-app>
15+
16+
<ion-header>
17+
<ion-toolbar>
18+
<ion-title>Select - Conflict</ion-title>
19+
</ion-toolbar>
20+
</ion-header>
21+
22+
<ion-content>
23+
<ion-list>
24+
25+
<ion-item>
26+
<ion-label>Alert</ion-label>
27+
<ion-select id="alert" placeholder="Select One" interface="alert">
28+
<ion-select-option class="s-unselected">Unselected</ion-select-option>
29+
<ion-select-option class="s-zero">Zero</ion-select-option>
30+
<ion-select-option class="s-empty">Empty String</ion-select-option>
31+
<ion-select-option class="s-null">Null</ion-select-option>
32+
</ion-select>
33+
</ion-item>
34+
35+
<ion-item>
36+
<ion-label>Action-sheet</ion-label>
37+
<ion-select id="action" placeholder="Select One" interface="action-sheet">
38+
<ion-select-option class="s-unselected">Unselected</ion-select-option>
39+
<ion-select-option class="s-zero">Zero</ion-select-option>
40+
<ion-select-option class="s-empty">Empty String</ion-select-option>
41+
<ion-select-option class="s-null">Null</ion-select-option>
42+
</ion-select>
43+
</ion-item>
44+
45+
<ion-item>
46+
<ion-label>Popover</ion-label>
47+
<ion-select id="popover" placeholder="Select One" interface="popover">
48+
<ion-select-option class="s-unselected">Unselected</ion-select-option>
49+
<ion-select-option class="s-zero">Zero</ion-select-option>
50+
<ion-select-option class="s-empty">Empty String</ion-select-option>
51+
<ion-select-option class="s-null">Null</ion-select-option>
52+
</ion-select>
53+
</ion-item>
54+
55+
<span id="results"></span>
56+
57+
</ion-list>
58+
59+
</ion-content>
60+
61+
<script>
62+
Array.from(document.querySelectorAll('.s-unselected')).forEach(s => s.value = undefined);
63+
Array.from(document.querySelectorAll('.s-zero')).forEach(s => s.value = 0);
64+
Array.from(document.querySelectorAll('.s-empty')).forEach(s => s.value = '');
65+
Array.from(document.querySelectorAll('.s-null')).forEach(s => s.value = null);
66+
67+
function updateValues() {
68+
const alert = document.getElementById('alert').value;
69+
const actionSheet = document.getElementById('action').value;
70+
const popover = document.getElementById('popover').value;
71+
72+
document.getElementById('results').textContent = `
73+
Alert: ${alert}
74+
Action-sheet: ${actionSheet}
75+
Popover: ${popover}
76+
`;
77+
}
78+
document.addEventListener('ionChange', () => updateValues());
79+
</script>
80+
</ion-app>
81+
</body>
82+
83+
</html>

0 commit comments

Comments
 (0)