Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit efa40c0

Browse files
committed
Merge branch '564-bug-date-picker-removal'
2 parents 776872c + ee63974 commit efa40c0

File tree

6 files changed

+51
-54
lines changed

6 files changed

+51
-54
lines changed

src/components/cellTypes/CalendarCell.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ const CalendarCell = (calendarProps: CellComponentProps) => {
5959
<Portal container={activeDocument.body}>{containerProps.children}</Portal>
6060
);
6161
};
62+
63+
const onClickOutside = () => {
64+
setShowDatePicker(false);
65+
};
66+
6267
return showDatePicker ? (
6368
<DatePicker
6469
dateFormat="yyyy-MM-dd"
@@ -69,10 +74,10 @@ const CalendarCell = (calendarProps: CellComponentProps) => {
6974
}
7075
onChange={handleCalendarChange}
7176
popperContainer={CalendarContainer}
72-
onBlur={() => setShowDatePicker(false)}
77+
onClickOutside={onClickOutside}
7378
autoFocus
7479
isClearable
75-
clearButtonTitle="Clear"
80+
ariaLabelClose="Clear"
7681
placeholderText="Pick a date..."
7782
/>
7883
) : (

src/components/cellTypes/CalendarTimeCell.tsx

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { CellComponentProps } from "cdm/ComponentsModel";
66
import { TableColumn } from "cdm/FolderModel";
77
import { ParseService } from "services/ParseService";
88
import { InputType } from "helpers/Constants";
9+
import { c } from "helpers/StylesHelper";
910

1011
const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
1112
const { defaultCell } = calendarTimeProps;
@@ -35,7 +36,7 @@ const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
3536
setShowDatePicker(true);
3637
}
3738

38-
function handleCalendarChange(date: Date) {
39+
async function handleCalendarChange(date: Date) {
3940
const changed = date !== null ? DateTime.fromJSDate(date) : null;
4041

4142
const newCell = ParseService.parseRowToLiteral(
@@ -44,7 +45,7 @@ const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
4445
changed
4546
);
4647

47-
dataActions.updateCell(
48+
await dataActions.updateCell(
4849
row.index,
4950
tableColumn,
5051
newCell,
@@ -62,36 +63,36 @@ const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
6263

6364
return showDatePicker &&
6465
(tableColumn.isMetadata === undefined || !tableColumn.isMetadata) ? (
65-
<div className="calendar-time">
66-
<DatePicker
67-
dateFormat={configInfo.getLocalSettings().datetime_format}
68-
selected={
69-
DateTime.isDateTime(calendarCell)
70-
? (calendarCell as unknown as DateTime).toJSDate()
71-
: null
72-
}
73-
onChange={handleCalendarChange}
74-
popperContainer={CalendarContainer}
75-
onBlur={() => setShowDatePicker(false)}
76-
timeFormat="HH:mm"
77-
timeCaption="time"
78-
showTimeSelect
79-
autoFocus
80-
isClearable
81-
clearButtonTitle="Clear"
82-
placeholderText="Pick a moment..."
83-
/>
84-
</div>
66+
<DatePicker
67+
dateFormat={configInfo.getLocalSettings().datetime_format}
68+
selected={
69+
DateTime.isDateTime(calendarCell)
70+
? (calendarCell as unknown as DateTime).toJSDate()
71+
: null
72+
}
73+
onChange={handleCalendarChange}
74+
popperContainer={CalendarContainer}
75+
onClickOutside={() => setShowDatePicker(false)}
76+
timeFormat="HH:mm"
77+
timeCaption="time"
78+
showTimeSelect
79+
autoFocus
80+
isClearable
81+
ariaLabelClose="Clear"
82+
placeholderText="Pick a moment..."
83+
/>
8584
) : (
86-
<div onClick={handleSpanOnClick}>
87-
<span className="calendar-time" style={{ width: column.getSize() }}>
88-
{DateTime.isDateTime(calendarCell)
89-
? (calendarCell as DateTime).toFormat(
90-
configInfo.getLocalSettings().datetime_format
91-
)
92-
: null}
93-
</span>
94-
</div>
85+
<span
86+
className={`${c("calendar")}`}
87+
style={{ width: column.getSize() }}
88+
onClick={handleSpanOnClick}
89+
>
90+
{DateTime.isDateTime(calendarCell)
91+
? (calendarCell as DateTime).toFormat(
92+
configInfo.getLocalSettings().datetime_format
93+
)
94+
: null}
95+
</span>
9596
);
9697
};
9798

src/parsers/RowDatabaseFieldsToFile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function parseValuetoSanitizeYamlValue(value: string, localSettings: Loca
3333

3434
function stringifyDbYaml(literal: Literal, level: number, localSettings: LocalSettings, key?: string): string[] {
3535
const literalBlock: string[] = [];
36-
literal = DataviewService.parseDataArray(literal);
36+
literal = ParseService.parseDataArray(literal);
3737
// Manage Arrays
3838
if (DataviewService.getDataviewAPI().value.isArray(literal)) {
3939
literalBlock.push(`${" ".repeat(level)}${key}:`);

src/services/DataviewService.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ class DataviewProxy {
2626
return this.getDataviewAPI().value.isTruthy(literal?.toString());
2727
}
2828

29-
/**
30-
* Check if literal is Proxy DataArray, if so, parse it. If not, return same literal
31-
* @param literal
32-
* @returns
33-
*/
34-
parseDataArray(literal: Literal): Literal {
35-
if ((literal as any).values !== undefined && (literal as any).settings !== undefined) {
36-
literal = (literal as any).values
37-
}
38-
return literal;
39-
}
4029
/**
4130
* Singleton instance
4231
* @returns {VaultManager}

src/services/ParseService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ class Parse {
7878
* @returns
7979
*/
8080
public parseDataArray(literal: Literal): Literal {
81-
if ((literal as any).values !== undefined && (literal as any).settings !== undefined) {
81+
if (literal === null || literal === undefined) {
82+
return literal;
83+
}
84+
85+
if (typeof literal === 'object' &&
86+
(literal as any).values !== undefined && (literal as any).settings !== undefined) {
8287
literal = (literal as any).values
8388
}
89+
8490
return literal;
8591
}
8692

styles.css

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,8 +1386,8 @@ div.database-plugin__checkbox {
13861386
}
13871387

13881388
.react-datepicker__input-container {
1389-
position: relative;
1390-
display: inline-block;
1389+
display: flex;
1390+
justify-content: space-around;
13911391
width: 100%;
13921392
}
13931393

@@ -1520,17 +1520,13 @@ div.database-plugin__checkbox {
15201520
border: 0;
15211521
box-shadow: none;
15221522
outline: 0;
1523-
padding: 0 6px 0 0;
1524-
position: absolute;
1525-
top: 0;
1523+
padding: 6px;
15261524
right: 0;
1527-
display: table-cell;
1528-
vertical-align: middle;
1525+
align-self: center;
15291526
}
15301527

15311528
.react-datepicker__close-icon::after {
15321529
cursor: pointer;
1533-
background-color: var(--text-accent);
15341530
color: var(--text-primary);
15351531
border-radius: 50%;
15361532
text-align: center;

0 commit comments

Comments
 (0)