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

Show the "Can't be blank" message under the password input #1882

Merged
merged 2 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions css/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ loadingSize = 30px
.auth0-lock-password-strength
width 100%
bottom 41px
left 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the password strength field is position relative to the password input, we have to add left 0 to take the padding for the icon into account (other wise the password strength tooltip would be 40px to the right)

// width calc(100% - 28px)
display block
text-align left
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ exports[`InputWrap renders correctly with the \`after\` prop 1`] = `
>
<div
className="auth0-lock-input-wrap"
/>
<span>
after
</span>
>
<span>
after
</span>
</div>
</div>
`;
6 changes: 6 additions & 0 deletions src/__tests__/ui/input/password_input.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { mount, shallow } from 'enzyme';

import { mockComponent } from 'testUtils';
import { extractPropsFromWrapper } from '../../testUtils';
import InputWrap from '../../../ui/input/input_wrap';

jest.mock('ui/input/input_wrap', () => mockComponent('input_wrap'));
jest.mock('ui/input/password/password_strength', () => mockComponent('password_strength'));
Expand Down Expand Up @@ -51,4 +52,9 @@ describe('PasswordInput', () => {
const wrapper = mount(<Input {...defaultProps} />);
expect(wrapper.find('input').props().autoComplete).toBe('off');
});
test('shows invalid Hint', () => {
const Input = getComponent();
const wrapper = mount(<Input {...defaultProps} />);
expect(wrapper.find(InputWrap).props().invalidHint).toBe('invalidHint');
});
});
2 changes: 1 addition & 1 deletion src/ui/input/input_wrap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export default class InputWrap extends React.Component {
<div className={wrapClassName}>
{iconElement}
{this.props.children}
{after}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component after is only ever the password strength field. I've made it positioned relative to this div, because it doesn't change height (the outer div does depending on the value of errorTooltip)

</div>
{after}
{errorTooltip}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/input/password_input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class PasswordInput extends React.Component {
<InputWrap
after={passwordStrength}
focused={focused}
invalidHint={policy ? undefined : invalidHint}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption is that this logic was added because we didn't want to reposition the password strength tooltip if there was an invalid hint.

invalidHint={invalidHint}
isValid={isValid}
name="password"
icon={icon}
Expand Down