Skip to content

Commit 1db1806

Browse files
committed
Sync radio button and input field for custom amount
- add "name=amount" to group the custom amount radio item with the other amount options - add "setCustomAmount" on click to focus the field https://phabricator.wikimedia.org/T395021
1 parent 4b6d85e commit 1db1806

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/components/shared/form_fields/AmountField.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131
<label class="form-field-amount-help-text" for="amount-custom">{{ $t('donation_form_payment_amount_label') }}</label>
3232
<div class="form-field-amount-custom-euro-symbol" :class="{ active: isCustomAmount }">
3333
<div class="radio radio-form-input">
34-
<input type="radio" class="form-field-amount-custom-radio" :checked="isCustomAmount" aria-hidden="true" tabindex="-1"/>
34+
<input
35+
name="amount"
36+
type="radio"
37+
class="form-field-amount-custom-radio"
38+
@click="setCustomAmount"
39+
:checked="isCustomAmount"
40+
aria-hidden="true"
41+
tabindex="-1"
42+
/>
3543
</div>
3644

3745
<TextFormInput

tests/unit/components/shared/form_fields/AmountField.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ describe( 'AmountField.vue', () => {
135135
expect( wrapper.find( '.form-field-amount-custom.active' ).exists() ).toBeFalsy();
136136
} );
137137

138+
it( 'custom amount radio is not activated by click', async () => {
139+
const wrapper = getWrapper();
140+
const customAmountRadioElement = wrapper.find( 'input[class="form-field-amount-custom-radio"]' );
141+
142+
await customAmountRadioElement.trigger( 'click' );
143+
144+
expect( wrapper.find( '.form-field-amount-custom.active' ).exists() ).toBeFalsy();
145+
} );
146+
138147
it( 'Checks the custom amount radio when value is custom', async () => {
139148
const wrapper = getWrapper();
140149
const customAmountInput = wrapper.find( '#amount-custom' );

0 commit comments

Comments
 (0)