Skip to content
Merged
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
19 changes: 17 additions & 2 deletions src/components/DatePicker/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import {Button, View, Keyboard} from 'react-native';
import RNDatePicker from '@react-native-community/datetimepicker';
import moment from 'moment';
import _ from 'underscore';
import compose from '../../libs/compose';
import TextInput from '../TextInput';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import Popover from '../Popover';
import CONST from '../../CONST';
import styles from '../../styles/styles';
import themeColors from '../../styles/themes/default';
import {propTypes, defaultProps} from './datepickerPropTypes';
import withKeyboardState, {keyboardStatePropTypes} from '../withKeyboardState';

const datepickerPropTypes = {
...propTypes,
...withLocalizePropTypes,
...keyboardStatePropTypes,
};

class DatePicker extends React.Component {
Expand All @@ -36,9 +39,18 @@ class DatePicker extends React.Component {
* @param {Event} event
*/
showPicker(event) {
// Opens the popover only after the keyboard is hidden to avoid a "blinking" effect where the keyboard was on iOS
// See https://github.com/Expensify/App/issues/14084 for more context
if (!this.props.isKeyboardShown) {
this.setState({isPickerVisible: true});
return;
}
const listener = Keyboard.addListener('keyboardDidHide', () => {
this.setState({isPickerVisible: true});
listener.remove();
});
Keyboard.dismiss();
this.initialValue = this.state.selectedDate;
this.setState({isPickerVisible: true});
event.preventDefault();
}

Expand Down Expand Up @@ -134,7 +146,10 @@ DatePicker.defaultProps = defaultProps;
* locale. Otherwise the spinner would be present in the system locale and it would be weird if it happens
* that the modal buttons are in one locale (app) while the (spinner) month names are another (system)
*/
export default withLocalize(React.forwardRef((props, ref) => (
export default compose(
withLocalize,
withKeyboardState,
)(React.forwardRef((props, ref) => (
/* eslint-disable-next-line react/jsx-props-no-spreading */
<DatePicker {...props} innerRef={ref} />
)));