Skip to content

Commit

Permalink
Merge pull request #1695 from visualize-admin/fix/manually-entering-date
Browse files Browse the repository at this point in the history
fix: Manually entering dates
  • Loading branch information
bprusinowski authored Aug 27, 2024
2 parents 3364bb0 + 88e6ae2 commit 115d54b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ You can also check the
- Drag handles are now centered in table configurator
- Single chart titles are now correctly displayed in user profile
- Renaming of charts through user profile now works correctly
- Manually entering dates in date pickers works correctly again

# [4.7.4] - 2024-07-23

Expand Down
1 change: 1 addition & 0 deletions app/charts/shared/chart-data-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ export const DataFilterTemporalDimension = ({
minDate={minDate}
maxDate={maxDate}
disabled={disabled}
parseDate={parseDate}
/>
) : (
<DataFilterGenericDimension
Expand Down
5 changes: 5 additions & 0 deletions app/configurator/components/field-date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type DatePickerFieldProps = {
sideControls?: React.ReactNode;
timeUnit?: DatePickerTimeUnit;
dateFormat?: (d: Date) => string;
parseDate: (s: string) => Date | null;
} & Omit<
DatePickerProps<Date>,
"value" | "onChange" | "shouldDisableDate" | "inputFormat" | "renderInput"
Expand All @@ -36,6 +37,7 @@ export const DatePickerField = (props: DatePickerFieldProps) => {
sideControls,
timeUnit = TimeUnit.Day,
dateFormat = timeFormat("%Y-%m-%d"),
parseDate,
...rest
} = props;
const handleChange = useCallback(
Expand Down Expand Up @@ -106,6 +108,9 @@ export const DatePickerField = (props: DatePickerFieldProps) => {
hiddenLabel
size="small"
{...params}
onChange={(e) => {
handleChange(parseDate(e.target.value));
}}
sx={{
...params.sx,

Expand Down
1 change: 1 addition & 0 deletions app/configurator/components/field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ export const DataFilterTemporal = ({
disabled={disabled || usesMostRecentDate}
topControls={topControls}
sideControls={sideControls}
parseDate={parseDate}
/>
<MostRecentDateSwitch
checked={usesMostRecentDate}
Expand Down
2 changes: 2 additions & 0 deletions app/configurator/components/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ export const TimeFilter = (props: TimeFilterProps) => {
dateFormat={formatDateValue}
minDate={from}
maxDate={to}
parseDate={parse}
/>
}
right={
Expand All @@ -1049,6 +1050,7 @@ export const TimeFilter = (props: TimeFilterProps) => {
dateFormat={formatDateValue}
minDate={from}
maxDate={to}
parseDate={parse}
/>
}
/>
Expand Down
2 changes: 2 additions & 0 deletions app/configurator/components/layout-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ const DashboardTimeRangeFilterOptions = ({
minDate={minDate}
maxDate={maxDate}
label={t({ id: "controls.filters.select.from", message: "From" })}
parseDate={parseDate}
/>
) : (
<Select
Expand All @@ -582,6 +583,7 @@ const DashboardTimeRangeFilterOptions = ({
minDate={minDate}
maxDate={maxDate}
label={t({ id: "controls.filters.select.to", message: "To" })}
parseDate={parseDate}
/>
) : (
<Select
Expand Down

0 comments on commit 115d54b

Please sign in to comment.