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

fix Locale Picker and small picker styles #4810

Merged
merged 4 commits into from
Aug 27, 2021
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
10 changes: 10 additions & 0 deletions src/CONST.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/components/Picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const Picker = ({
fixAndroidTouchableBug
onOpen={onOpen}
onClose={onClose}
pickerProps={{
onFocus: onOpen,
onBlur: onClose,
}}
Beamanator marked this conversation as resolved.
Show resolved Hide resolved
/>
);

Expand Down
19 changes: 18 additions & 1 deletion src/components/Picker/pickerStyles/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import CONST from '../../../CONST';
import getBrowser from '../../../libs/getBrowser';
import styles from '../../../styles/styles';

const pickerStyles = disabled => styles.expensiPicker(disabled);
const pickerStylesWeb = () => {
if (CONST.BROWSER.FIREFOX === getBrowser()) {
return {
textIndent: -2,
};
}
return {};
};

const pickerStyles = disabled => ({
...styles.expensiPicker(disabled),
inputWeb: {
...styles.expensiPicker(disabled).inputWeb,
...pickerStylesWeb(),
},
});

export default pickerStyles;
4 changes: 3 additions & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function setCurrentURL(url) {
* @param {String} locale
*/
function setLocale(locale) {
API.PreferredLocale_Update({name: 'preferredLocale', value: locale});
if (currentUserAccountID) {
API.PreferredLocale_Update({name: 'preferredLocale', value: locale});
}
Onyx.merge(ONYXKEYS.NVP_PREFERRED_LOCALE, locale);
}

Expand Down
1 change: 1 addition & 0 deletions src/libs/getBrowser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => '';
42 changes: 42 additions & 0 deletions src/libs/getBrowser/index.web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import CONST from '../../CONST';

/**
* Fetch browser name from UA string
*
* @return {String} e.g. Chrome
*/
function getBrowser() {
const {userAgent} = window.navigator;
let match = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))/i) || [];
let temp;

if (/trident/i.test(match[1])) {
return 'IE';
}

if (match[1] && (match[1].toLowerCase() === 'chrome')) {
temp = userAgent.match(/\b(OPR|Edge)\/(\d+)/);

if (temp !== null) {
return temp.slice(1).replace('OPR', 'Opera');
}

temp = userAgent.match(/\b(Edg)\/(\d+)/);

if (temp !== null) {
return temp.slice(1).replace('Edg', 'Edge');
}
}

match = match[1] ? match[1] : navigator.appName;
return match;
}

/**
* Get the Browser name
* @returns {String}
*/
export default () => {
const browser = getBrowser();
return browser ? browser.toLowerCase() : CONST.BROWSER.OTHER;
};
3 changes: 3 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ const styles = {
borderRadius: variables.componentBorderRadius,
borderWidth: 1,
borderColor: themeColors.border,
borderStyle: 'solid',
color: themeColors.text,
height: variables.componentSizeSmall,
opacity: 1,
Expand All @@ -385,6 +386,7 @@ const styles = {
borderWidth: 1,
borderRadius: variables.componentBorderRadius,
borderColor: themeColors.border,
borderStyle: 'solid',
color: themeColors.text,
appearance: 'none',
height: variables.componentSizeSmall,
Expand All @@ -402,6 +404,7 @@ const styles = {
borderWidth: 1,
borderRadius: variables.componentBorderRadius,
borderColor: themeColors.border,
borderStyle: 'solid',
color: themeColors.text,
height: variables.componentSizeSmall,
opacity: 1,
Expand Down