Skip to content

Commit b51aadc

Browse files
glo80771glo82145
andauthored
Pwa 3122 (#4104)
* PWA-3121::system is getting crashed with unexpected error when pressed Retrun button with invalid Gift card number * PWA-3121::Updated test cases * PWA-3121::Formatted the code using prettier * PWA-3122::System does not read displayed error message for accessibil users, if User press Return Button with blank Gift card number * PWA-3122::Formatted the code using prettier --------- Co-authored-by: Aanchal Pawar <97873570+glo82145@users.noreply.github.com>
1 parent 87358c7 commit b51aadc

File tree

3 files changed

+49
-17
lines changed

3 files changed

+49
-17
lines changed

packages/venia-ui/lib/components/CartPage/GiftCards/__tests__/__snapshots__/giftCards.spec.js.snap

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ exports[`it renders correctly when it has cards 1`] = `
6262
className="root"
6363
/>
6464
</div>
65+
<span
66+
aria-live="polite"
67+
>
68+
<div
69+
className="balance"
70+
>
71+
<span
72+
className="invalid_card_error"
73+
/>
74+
</div>
75+
</span>
6576
</div>
6677
<div
6778
className="root"
@@ -303,6 +314,17 @@ exports[`it renders correctly with no cards 1`] = `
303314
className="root"
304315
/>
305316
</div>
317+
<span
318+
aria-live="polite"
319+
>
320+
<div
321+
className="balance"
322+
>
323+
<span
324+
className="invalid_card_error"
325+
/>
326+
</div>
327+
</span>
306328
</div>
307329
<div
308330
className="root"

packages/venia-ui/lib/components/CartPage/GiftCards/giftCards.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,31 @@ const GiftCards = props => {
133133
);
134134
}
135135

136-
const cardBalance = shouldDisplayCardBalance && (
137-
<div className={classes.balance}>
138-
<span className={classes.price}>
139-
<FormattedMessage
140-
id={'giftCards.balance'}
141-
defaultMessage={'Balance: '}
142-
/>
143-
<Price
144-
value={checkBalanceData.balance.value}
145-
currencyCode={checkBalanceData.balance.currency}
146-
/>
147-
</span>
148-
</div>
149-
);
150-
151136
const containerClass = shouldDisplayCardError
152137
? classes.card_input_container_error
153138
: classes.card_input_container;
154139

140+
const cardBalance = (
141+
<div className={classes.balance}>
142+
{checkBalanceData && shouldDisplayCardBalance ? (
143+
<div className={classes.price}>
144+
<FormattedMessage
145+
id={'giftCards.balance'}
146+
defaultMessage={'Balance: '}
147+
/>
148+
<Price
149+
value={checkBalanceData.balance.value}
150+
currencyCode={checkBalanceData.balance.currency}
151+
/>
152+
</div>
153+
) : (
154+
<span className={classes.invalid_card_error}>
155+
{cardEntryErrorMessage}
156+
</span>
157+
)}
158+
</div>
159+
);
160+
155161
const cardEntryContents = (
156162
<div className={classes.card}>
157163
<Field
@@ -172,15 +178,15 @@ const GiftCards = props => {
172178
field="card"
173179
mask={value => value && value.trim()}
174180
maskOnBlur={true}
175-
message={cardEntryErrorMessage}
181+
// message={cardEntryErrorMessage}
176182
placeholder={formatMessage({
177183
id: 'giftCards.cardEntry',
178184
defaultMessage: 'Enter card number'
179185
})}
180186
validate={isRequired}
181187
/>
182188
</div>
183-
{cardBalance}
189+
<span aria-live="polite">{cardBalance}</span>
184190
</Field>
185191
<Field
186192
classes={{

packages/venia-ui/lib/components/CartPage/GiftCards/giftCards.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
.card_input_container {
4242
}
4343

44+
.invalid_card_error {
45+
color: red;
46+
}
47+
4448
/* TODO @TW: cannot compose */
4549
.card_input_container_error input {
4650
/* composes: border-error from global; */

0 commit comments

Comments
 (0)