Skip to content

Commit ae19f35

Browse files
Merge pull request #264 from jcloquell/fix-date-picker-allow-editing
Fix the allowEditing prop which was being accidentally ignored
2 parents bf73235 + afcb7a9 commit ae19f35

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

example/src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ function App() {
306306
// animationType="slide" // optional, default is slide on ios/android and none on web
307307
// startYear={2000} // optional, default is 1800
308308
// endYear={2100} // optional, default is 2200
309+
// allowEditing={false} // optional, default is true
310+
// inputEnabled={false} // optional, default is true
309311
/>
310312

311313
<DatePickerModal
@@ -327,6 +329,8 @@ function App() {
327329
// animationType="slide" // optional, default is 'slide' on ios/android and 'none' on web
328330
// startYear={2000} // optional, default is 1800
329331
// endYear={2100} // optional, default is 2200
332+
// allowEditing={false} // optional, default is true
333+
// inputEnabled={false} // optional, default is true
330334
/>
331335

332336
<DatePickerModal

src/Date/DatePickerModalContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function DatePickerModalContent(
165165
locale={locale}
166166
editIcon={props?.editIcon}
167167
calendarIcon={props.calendarIcon}
168-
allowEditing={props.allowEditing || true}
168+
allowEditing={props.allowEditing ?? true}
169169
/>
170170
</DatePickerModalHeaderBackground>
171171
<AnimatedCrossView

src/Date/DatePickerModalContentHeader.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export interface HeaderContentProps extends HeaderPickProps {
2828
collapsed: boolean
2929
onToggle: () => any
3030
locale: string | undefined
31-
inputDate?: boolean
3231
}
3332

3433
function getLabel(
@@ -62,15 +61,14 @@ export default function DatePickerModalContentHeader(
6261
uppercase,
6362
editIcon,
6463
calendarIcon,
65-
inputDate,
6664
allowEditing,
6765
} = props
6866
const theme = useTheme()
6967
const label = getLabel(props.locale, props.mode, props.label)
7068

7169
const color = useHeaderTextColor()
7270

73-
const isAllowEditing = allowEditing && mode !== 'multiple' && inputDate !== undefined
71+
const isEditingEnabled = allowEditing && mode !== 'multiple'
7472

7573
const supportingTextColor = theme.isV3 ? theme.colors.onSurfaceVariant : color
7674

@@ -103,7 +101,7 @@ export default function DatePickerModalContentHeader(
103101
</View>
104102
</View>
105103
<View style={styles.fill} />
106-
{isAllowEditing ? (
104+
{isEditingEnabled ? (
107105
<IconButton
108106
icon={
109107
collapsed

src/__tests__/Date/__snapshots__/AnimatedCrossView.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ exports[`renders collapsed AnimatedCrossView 1`] = `
488488
onScrollEndDrag={[Function]}
489489
removeClippedSubviews={false}
490490
renderItem={[Function]}
491+
renderScrollComponent={[Function]}
491492
scrollEventThrottle={50}
492493
stickyHeaderIndices={[]}
493494
style={

src/__tests__/Date/__snapshots__/Calendar.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ exports[`renders Calendar 1`] = `
463463
onScrollEndDrag={[Function]}
464464
removeClippedSubviews={false}
465465
renderItem={[Function]}
466+
renderScrollComponent={[Function]}
466467
scrollEventThrottle={50}
467468
stickyHeaderIndices={[]}
468469
style={

src/__tests__/Date/__snapshots__/YearPicker.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ exports[`renders YearPicker 1`] = `
444444
onScrollEndDrag={[Function]}
445445
removeClippedSubviews={false}
446446
renderItem={[Function]}
447+
renderScrollComponent={[Function]}
447448
scrollEventThrottle={50}
448449
stickyHeaderIndices={[]}
449450
style={

0 commit comments

Comments
 (0)