Skip to content

Commit

Permalink
Performance Profiler: fix historical graph rendering issue on safari (#…
Browse files Browse the repository at this point in the history
…94273)

* Performance Profiler: fix historical graph rendering issue on safari

* move utility function out of inline map

* add better comment
  • Loading branch information
gavande1 authored Sep 6, 2024
1 parent e776232 commit 0a8ca80
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export const CoreWebVitalsDetails: React.FC< CoreWebVitalsDetailsProps > = ( {
return '';
};

// Add leading zero to date values. Safari expects the date string to follow the ISO 8601 format (i.e., YYYY-MM-DD)
const addLeadingZero = ( value: number ) => {
if ( value < 10 ) {
return `0${ value }`;
}
return value;
};

let metricsData: number[] = history?.metrics[ activeTab ] ?? [];
let dates = history?.collection_period ?? [];

Expand All @@ -69,7 +77,7 @@ export const CoreWebVitalsDetails: React.FC< CoreWebVitalsDetailsProps > = ( {
formattedDate = date;
} else {
const { year, month, day } = date;
formattedDate = `${ year }-${ month }-${ day }`;
formattedDate = `${ year }-${ addLeadingZero( month ) }-${ addLeadingZero( day ) }`;
}

return {
Expand Down

0 comments on commit 0a8ca80

Please sign in to comment.