Skip to content

Commit 0795823

Browse files
authored
fix: set correct date time property in Time component (#5202)
All html attributes all converted to react style though in case of Time property was converted. The easiest solution is to rename the actual property to accept converted time.
1 parent 7f50fbe commit 0795823

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

packages/sdk-components-react/src/__generated__/time.props.ts

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk-components-react/src/time.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef, type ElementRef } from "react";
1+
import { forwardRef, type ComponentProps, type ElementRef } from "react";
22

33
const languages = [
44
"af",
@@ -345,8 +345,7 @@ const parseDate = (datetimeString: string) => {
345345
}
346346
};
347347

348-
type TimeProps = {
349-
datetime?: string;
348+
type TimeProps = Pick<ComponentProps<"time">, "dateTime"> & {
350349
language?: Language;
351350
country?: Country;
352351
dateStyle?: DateStyle;
@@ -360,7 +359,8 @@ export const Time = forwardRef<ElementRef<"time">, TimeProps>(
360359
country = DEFAULT_COUNTRY,
361360
dateStyle = DEFAULT_DATE_STYLE,
362361
timeStyle = DEFAULT_TIME_STYLE,
363-
datetime = INITIAL_DATE_STRING,
362+
// native html attribute in react style
363+
dateTime = INITIAL_DATE_STRING,
364364
...props
365365
},
366366
ref
@@ -375,7 +375,7 @@ export const Time = forwardRef<ElementRef<"time">, TimeProps>(
375375
};
376376

377377
const datetimeString =
378-
datetime === null ? INVALID_DATE_STRING : datetime.toString();
378+
dateTime === null ? INVALID_DATE_STRING : dateTime.toString();
379379

380380
const date = parseDate(datetimeString);
381381
let formattedDate = datetimeString;

0 commit comments

Comments
 (0)