From ec03f49b2d7d66139c324dcbb3741550af98aa6b Mon Sep 17 00:00:00 2001
From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com>
Date: Fri, 21 Oct 2022 13:52:12 -0300
Subject: [PATCH] [FIX] UiKit/DatePicker is broken (#4607)
* [FIX] UiKit/DatePicker is broken
* minor tweak
---
app/containers/UIKit/DatePicker.tsx | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/app/containers/UIKit/DatePicker.tsx b/app/containers/UIKit/DatePicker.tsx
index f962d0529..2466393bc 100644
--- a/app/containers/UIKit/DatePicker.tsx
+++ b/app/containers/UIKit/DatePicker.tsx
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
-import { StyleSheet, Text, View } from 'react-native';
+import { StyleSheet, Text, unstable_batchedUpdates, View } from 'react-native';
import DateTimePicker, { Event } from '@react-native-community/datetimepicker';
import Touchable from 'react-native-platform-touchable';
import { BlockContext } from '@rocket.chat/ui-kit';
@@ -48,11 +48,15 @@ export const DatePicker = ({ element, language, action, context, loading, value,
// timestamp as number exists in Event
// @ts-ignore
const onChange = ({ nativeEvent: { timestamp } }: Event, date?: Date) => {
- const newDate = date || new Date(timestamp);
- onChangeDate(newDate);
- action({ value: moment(newDate).format('YYYY-MM-DD') });
- if (isAndroid) {
- onShow(false);
+ if (date || timestamp) {
+ const newDate = date || new Date(timestamp);
+ unstable_batchedUpdates(() => {
+ onChangeDate(newDate);
+ if (isAndroid) {
+ onShow(false);
+ }
+ });
+ action({ value: moment(newDate).format('YYYY-MM-DD') });
}
};
@@ -85,7 +89,13 @@ export const DatePicker = ({ element, language, action, context, loading, value,
}
const content = show ? (
-
+
) : null;
return (