Skip to content

Commit 1a1d93b

Browse files
authored
Merge pull request #375 from qonto/em-input-id
Add named argument `@inputId` to allow setting the input id
2 parents bc9e793 + d662ade commit 1a1d93b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

addon/components/amount-input.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<input
77
class="amount-input__value {{@inputClass}} {{if @disabled 'disabled'}}"
8-
id='amount-input'
8+
id={{this.inputId}}
99
type='number'
1010
value={{@value}}
1111
step={{this.step}}

addon/components/amount-input.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ export default class AmountInput extends Component {
4444
@type String?
4545
*/
4646

47+
/**
48+
A custom id applied on the input
49+
@argument inputId
50+
@type String?
51+
*/
52+
get inputId() {
53+
return this.argOrDefault('inputId', 'amount-input')
54+
}
55+
4756
/**
4857
Defines the argument sent to toFixed()
4958
Can be n>=0

tests/integration/components/amount-input/component-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module('Integration | Component | amount-input', function(hooks) {
2020

2121
await render(hbs`
2222
<AmountInput
23+
@inputId='abcd'
2324
@currency="USD"
2425
@numberOfDecimal={{0}}
2526
@placeholder="1.000.000"
@@ -30,6 +31,7 @@ module('Integration | Component | amount-input', function(hooks) {
3031

3132
assert.dom('.amount-input__currency').hasText('USD')
3233
assert.dom('input').hasValue('1')
34+
assert.dom('input').hasAttribute('id', 'abcd')
3335

3436
await fillIn('input', '10.726')
3537
await blur('input')
@@ -46,11 +48,13 @@ module('Integration | Component | amount-input', function(hooks) {
4648
@numberOfDecimal={{this.isUndefined}}
4749
@placeholder={{this.isUndefined}}
4850
@step={{this.isUndefined}}
51+
@inputId={{this.isUndefined}}
4952
@value={{this.value}}
5053
@update={{fn (mut this.value)}} />
5154
`)
5255
assert.dom('.amount-input__currency').hasText('')
5356
assert.dom('input').hasNoAttribute('placeholder')
57+
assert.dom('input').hasNoAttribute('id')
5458

5559
// test numberOfDecimal
5660
await fillIn('input', '10.726')
@@ -68,6 +72,7 @@ module('Integration | Component | amount-input', function(hooks) {
6872

6973
assert.dom('.amount-input__currency').hasText('EUR')
7074
assert.dom('input').hasAttribute('placeholder', '0.00')
75+
assert.dom('input').hasAttribute('id', 'amount-input')
7176

7277
// test numberOfDecimal
7378
await fillIn('input', '10.726')

0 commit comments

Comments
 (0)