Skip to content

Commit

Permalink
- Fix bug where date description was cleared when the date value was …
Browse files Browse the repository at this point in the history
…cleared.
  • Loading branch information
mattias800 committed Sep 3, 2024
1 parent 6b892dc commit dd87ae4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from "react";
import { FocusEventHandler, useCallback, useRef, useState } from "react";
import {
LabelledTextInput,
LabelledTextInputProps,
} from "@stenajs-webui/forms";
import { FocusEventHandler, useCallback, useRef, useState } from "react";
import {
InputMask,
InputMaskPipe,
Expand Down Expand Up @@ -84,7 +84,7 @@ export const TravelDateTextInput: React.FC<TravelDateTextInputProps> = ({
<LabelledTextInput
{...inputProps}
aria-live={"polite"}
value={!isFocused ? valueWhenBlurred : undefined}
value={(!isFocused ? valueWhenBlurred : value) ?? ""}
ref={inputRef}
placeholder={activePlaceholder}
onFocus={onFocusHandler}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ export const useTravelDateRangeInput = (
selectedStartDate != null
? formatDateDescription(selectedStartDate, today, locale)
: undefined,
[locale, selectedStartDate]
[locale, selectedStartDate, today]
);

const valueWhenBlurredEndDate = useMemo(
() =>
selectedEndDate != null
? formatDateDescription(selectedEndDate, today, locale)
: undefined,
[locale, selectedEndDate]
[locale, selectedEndDate, today]
);

const [visibleMonth, setVisibleMonth] = useState<Date>(
Expand Down

0 comments on commit dd87ae4

Please sign in to comment.