Skip to content

Commit 59b71f6

Browse files
authored
Fix Picker to use new dialog and also fix height issues (#3331)
1 parent 6647850 commit 59b71f6

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

demo/src/screens/componentScreens/PickerScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ export default class PickerScreen extends Component {
191191
<Button link label="Done" onPress={onDone}/>
192192
</View>
193193
)}
194-
customPickerProps={{migrateDialog: true, dialogProps: {bottom: true, width: '100%', height: '45%'}}}
195194
showSearch
196195
searchPlaceholder={'Search a language'}
197196
items={dialogOptions}

src/components/actionSheet/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ class ActionSheet extends Component<ActionSheetProps> {
255255
}
256256

257257
return (
258-
// @ts-expect-error height might be null here
259258
<IncubatorDialog
260259
bottom
261260
centerH

src/components/picker/PickerItemsList.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import React, {useCallback, useContext, useState, useMemo} from 'react';
2+
import React, {useCallback, useContext, useState} from 'react';
33
import {StyleSheet, FlatList, TextInput, ListRenderItemInfo, ActivityIndicator} from 'react-native';
44
import {Typography, Colors} from '../../style';
55
import Assets from '../../assets';
@@ -39,13 +39,6 @@ const PickerItemsList = (props: PickerItemsListProps) => {
3939
const context = useContext(PickerContext);
4040

4141
const [wheelPickerValue, setWheelPickerValue] = useState<PickerSingleValue>(context.value ?? items?.[0]?.value);
42-
// TODO: Might not need this memoized style, instead we can move it to a stylesheet
43-
const wrapperContainerStyle = useMemo(() => {
44-
// const shouldFlex = Constants.isWeb ? 1 : useDialog ? 1 : 1;
45-
const shouldFlex = true;
46-
const style = {flex: shouldFlex ? 1 : 0, maxHeight: Constants.isWeb ? Constants.windowHeight * 0.75 : undefined};
47-
return style;
48-
}, [/* useDialog */]);
4942

5043
const renderSearchInput = () => {
5144
if (showSearch) {
@@ -180,7 +173,7 @@ const PickerItemsList = (props: PickerItemsListProps) => {
180173
};
181174

182175
return (
183-
<View style={wrapperContainerStyle} useSafeArea={useSafeArea}>
176+
<View style={styles.container} useSafeArea={useSafeArea}>
184177
{renderPickerHeader()}
185178
{showLoader ? renderLoader() : renderContent()}
186179
</View>
@@ -189,6 +182,11 @@ const PickerItemsList = (props: PickerItemsListProps) => {
189182

190183
const styles = StyleSheet.create({
191184
modalBody: {},
185+
container: {
186+
minHeight: 250,
187+
flexShrink: 1,
188+
maxHeight: Constants.isWeb ? Constants.windowHeight * 0.75 : undefined
189+
},
192190
searchInputContainer: {
193191
flexDirection: 'row',
194192
alignItems: 'center',

src/components/picker/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import {
3030
PickerItemsListProps,
3131
PickerMethods
3232
} from './types';
33+
import {DialogProps} from '../../incubator/Dialog';
3334

34-
const DIALOG_PROPS = {
35+
const DEFAULT_DIALOG_PROPS: DialogProps = {
3536
bottom: true,
36-
width: '100%',
37-
height: 250
37+
width: '100%'
3838
};
3939

4040
type PickerStatics = {
@@ -278,7 +278,8 @@ const Picker = React.forwardRef((props: PickerProps, ref) => {
278278
<ExpandableOverlay
279279
ref={pickerExpandable}
280280
useDialog={useDialog || useWheelPicker}
281-
dialogProps={DIALOG_PROPS}
281+
dialogProps={DEFAULT_DIALOG_PROPS}
282+
migrateDialog
282283
expandableContent={expandableModalContent}
283284
renderCustomOverlay={renderOverlay ? _renderOverlay : undefined}
284285
onPress={onPress}

src/incubator/Dialog/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export interface _DialogProps extends AlignmentModifiers, Pick<ViewProps, 'useSa
105105
/**
106106
* The dialog height.
107107
*/
108-
height?: string | number;
108+
height?: string | number | null;
109109

110110
/**
111111
* Callback that is called after the dialog's dismiss (after the animation has ended).

src/incubator/expandableOverlay/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ const ExpandableOverlay = (props: ExpandableOverlayProps, ref: any) => {
106106
const renderDialog = () => {
107107
const Dialog = migrateDialog ? DialogNew : DialogOld;
108108
return (
109-
// @ts-expect-error
110109
<Dialog testID={`${testID}.overlay`} {...dialogProps} visible={visible} onDismiss={closeExpandable}>
111110
{expandableContent}
112111
</Dialog>

0 commit comments

Comments
 (0)