Skip to content

Commit 5bbfcf2

Browse files
committed
PasswordInput: Fix overlap for long passwords and show/hide button
Long passwords and show/hide buttons overlap with each other. I fixed this problem by doing the following: - I changed the style of Password Input to take up as much space as needed. I did this by setting a flex of 1 to the Password Input. - I changed the positioning of the show/hide button from absolute to relative. - I ensured horizontal alignment by setting the flex-direction of the parent view to 'row'. - To fix the problem of the changing width of the text input, when the show/hide text changes, I replaced the show/hide text with a show/icon. The show/hide icon is an eye-open/eye-closed icon. This icon always has a fixed width and does not affect the text input. - I removed hide text from messages_en.json since it is not in the app. I tested this on Android and IOS devices with different screen sizes, and it works fine on both platforms. Fixes: zulip#5614
1 parent ff4e8a3 commit 5bbfcf2

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/common/PasswordInput.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@ import React, { useState, useCallback } from 'react';
33
import type { Node } from 'react';
44
import { View } from 'react-native';
55

6+
import { Icon } from './Icons';
67
import Input from './Input';
78
import type { Props as InputProps } from './Input';
89
import { BRAND_COLOR, createStyleSheet } from '../styles';
9-
import ZulipTextIntl from './ZulipTextIntl';
1010
import Touchable from './Touchable';
1111

1212
const styles = createStyleSheet({
1313
showPasswordButton: {
14-
position: 'absolute',
15-
right: 0,
16-
top: 0,
17-
bottom: 0,
1814
justifyContent: 'center',
1915
},
20-
showPasswordButtonText: {
16+
showPasswordButtonIcon: {
2117
margin: 8,
2218
color: BRAND_COLOR,
2319
},
20+
passwordTextInput: {
21+
flex: 1,
22+
},
23+
passwordInputView: {
24+
flexDirection: 'row',
25+
},
2426
});
2527

2628
// Prettier wants a ", >" here, which is silly.
@@ -44,10 +46,16 @@ export default function PasswordInput(props: Props): Node {
4446
}, []);
4547

4648
return (
47-
<View>
48-
<Input {...props} secureTextEntry={isHidden} autoCorrect={false} autoCapitalize="none" />
49+
<View style={styles.passwordInputView}>
50+
<Input
51+
{...props}
52+
secureTextEntry={isHidden}
53+
autoCorrect={false}
54+
autoCapitalize="none"
55+
style={styles.passwordTextInput}
56+
/>
4957
<Touchable style={styles.showPasswordButton} onPress={handleShow}>
50-
<ZulipTextIntl style={styles.showPasswordButtonText} text={isHidden ? 'show' : 'hide'} />
58+
<Icon name={isHidden ? 'eye-off' : 'eye'} size={24} style={styles.showPasswordButtonIcon} />
5159
</Touchable>
5260
</View>
5361
);

static/translations/messages_en.json

-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@
277277
"Stream settings": "Stream settings",
278278
"Failed to show stream settings": "Failed to show stream settings",
279279
"show": "show",
280-
"hide": "hide",
281280
"Debug": "Debug",
282281
"Administrators": "Administrators",
283282
"Normal users": "Normal users",

0 commit comments

Comments
 (0)