Skip to content

Commit

Permalink
Merge pull request #280 from komarovalexander/dev
Browse files Browse the repository at this point in the history
Fix timezone issue on default date editor
  • Loading branch information
komarovalexander authored Feb 9, 2023
2 parents 9fb68bc + 7583ca6 commit 37f7a71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ka-table",
"version": "7.8.4",
"version": "7.8.5",
"license": "MIT",
"repository": "github:komarovalexander/ka-table",
"homepage": "https://komarovalexander.github.io/ka-table/#/overview",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Components/CellEditorDate/CellEditorDate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('CellEditorDate', () => {
columnKey: 'fieldName',
rowKeyValue: 2,
type: ActionType.UpdateCellValue,
value: newValue,
value: new Date(newValue.getTime() + newValue.getTimezoneOffset() * 60000), // https://github.com/komarovalexander/ka-table/issues/279
});
});

Expand Down
13 changes: 8 additions & 5 deletions src/lib/Components/CellEditorDate/CellEditorDate.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';

import { closeEditor, updateCellValue } from '../../actionCreators';
import defaultOptions from '../../defaultOptions';

import { ICellEditorProps } from '../../props';
import { getElementCustomization } from '../../Utils/ComponentUtils';
import React from 'react';
import defaultOptions from '../../defaultOptions';
import { getDateInputValue } from '../../Utils/DateUtils';
import { getElementCustomization } from '../../Utils/ComponentUtils';

const CellEditorDate: React.FunctionComponent<ICellEditorProps> = (props) => {
const {
Expand All @@ -24,7 +24,10 @@ const CellEditorDate: React.FunctionComponent<ICellEditorProps> = (props) => {
onChange: (event) => {
const targetValue: string = event.currentTarget.value;
const newValue = targetValue ? new Date(targetValue) : null;
dispatch(updateCellValue(rowKeyValue, column.key, newValue));
dispatch(updateCellValue(
rowKeyValue,
column.key,
newValue && new Date(newValue.getTime() + newValue.getTimezoneOffset() * 60000)));
},
onBlur: () => dispatch(closeEditor(rowKeyValue, column.key))
}, props, childComponents?.cellEditorInput);
Expand Down

0 comments on commit 37f7a71

Please sign in to comment.