mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-06 06:48:21 +00:00
Exposed current view when changing the value of the default value property (#4786)
This commit is contained in:
parent
34f7be5bb2
commit
7fc641d12a
1 changed files with 13 additions and 3 deletions
|
|
@ -51,6 +51,7 @@ export const Calendar = function ({
|
|||
|
||||
const [currentDate, setCurrentDate] = useState(defaultDate);
|
||||
const [eventPopoverOptions, setEventPopoverOptions] = useState({ show: false });
|
||||
const [defaultView, setDefaultValue] = useState(allowedCalendarViews[0]);
|
||||
|
||||
const eventPropGetter = (event) => {
|
||||
const backgroundColor = event.color;
|
||||
|
|
@ -88,9 +89,16 @@ export const Calendar = function ({
|
|||
});
|
||||
}
|
||||
|
||||
const defaultView = allowedCalendarViews.includes(properties.defaultView)
|
||||
? properties.defaultView
|
||||
: allowedCalendarViews[0];
|
||||
useEffect(() => {
|
||||
const view = allowedCalendarViews.includes(properties.defaultView)
|
||||
? properties.defaultView
|
||||
: allowedCalendarViews[0];
|
||||
if (exposedVariables.currentView !== view) {
|
||||
setDefaultValue(view);
|
||||
setExposedVariable('currentView', view);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [properties.defaultView]);
|
||||
|
||||
useEffect(() => {
|
||||
//check if the default date is a valid date
|
||||
|
|
@ -132,7 +140,9 @@ export const Calendar = function ({
|
|||
style={style}
|
||||
views={allowedCalendarViews}
|
||||
defaultView={defaultView}
|
||||
view={defaultView}
|
||||
onView={(view) => {
|
||||
setDefaultValue(view);
|
||||
setExposedVariable('currentView', view);
|
||||
fireEvent('onCalendarViewChange');
|
||||
}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue