Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add md-input-has-placeholder class to input with placeholder #1083

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion addon/components/paper-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default Component.extend(FocusableMixin, ColorMixin, ChildMixin, Validati
'hasLeftIcon:md-icon-left',
'hasRightIcon:md-icon-right',
'focused:md-input-focused',
'block:md-block'
'block:md-block',
'placeholder:md-input-has-placeholder'
],
type: 'text',
autofocus: false,
Expand Down
21 changes: 20 additions & 1 deletion tests/integration/components/paper-input-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ module('Integration | Component | paper-input', function(hooks) {
});

test('renders input with placeholder', async function(assert) {
assert.expect(1);
assert.expect(2);

await render(hbs`{{paper-input placeholder="Enter value here" onChange=dummyOnChange}}`);

assert.dom('md-input-container input').hasAttribute('placeholder', 'Enter value here');
assert.dom('md-input-container').hasClass('md-input-has-placeholder');

});

Expand Down Expand Up @@ -517,6 +518,24 @@ module('Integration | Component | paper-input', function(hooks) {
assert.dom('.other-stuff').exists();
});

test('does not have md-input-has-placeholder class when no placeholder', async function(assert) {
assert.expect(1);

await render(hbs`{{paper-input onChange=dummyOnChange}}`);

assert.dom('md-input-container').doesNotHaveClass('md-input-has-placeholder');

});

test('does not have md-input-has-placeholder class when there is a label', async function(assert) {
assert.expect(1);

await render(hbs`{{paper-input label="Label here" onChange=dummyOnChange}}`);

assert.dom('md-input-container').doesNotHaveClass('md-input-has-placeholder');

});

test('aria-describedby on input elements is set properly', async function(assert) {

let errors = [{
Expand Down