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

Commit c25d291

Browse files
committed
Merge branch '561-date-picker-on-mobile'
2 parents efa40c0 + ac271c0 commit c25d291

File tree

7 files changed

+78
-58
lines changed

7 files changed

+78
-58
lines changed

docs/docs/changelog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
1+
## 2.8.2
2+
### Visual
3+
- UX improvements for date picker and time picker
4+
- Checkbox design improvements [randomsnowflake](https://github.com/randomsnowflake)
5+
### No longer broken
6+
- Tags are now properly saved when it's a number with decimals with zero at the end (e.g. 1.0, 1.00, 1.000, etc.)
7+
- Datepicker clear button now works properly [ISSUE#564](https://github.com/RafaelGB/obsidian-db-folder/issues/564)
8+
- Vertical scroll on mobile improved [ISSUE#488](https://github.com/RafaelGB/obsidian-db-folder/issues/488)
29
## 2.8.1
310
### Shiny new things
411
- New rollup functions: Count unique values,Truthy count, Falsy count, Percent empty, Percent filled, Task TODO, Task completed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@
5050
"dependencies": {
5151
"@emotion/styled": "11.10.5",
5252
"@mui/icons-material": "5.10.9",
53-
"@mui/material": "5.10.11",
53+
"@mui/material": "5.10.13",
5454
"@popperjs/core": "2.11.6",
5555
"@tanstack/match-sorter-utils": "8.5.14",
56-
"@tanstack/react-table": "8.5.21",
56+
"@tanstack/react-table": "8.5.22",
5757
"eventemitter3": "4.0.7",
5858
"fuse.js": "6.6.2",
59-
"luxon": "3.0.4",
59+
"luxon": "3.1.0",
6060
"monkey-around": "2.3.0",
61-
"obsidian-dataview": "0.5.47",
61+
"obsidian-dataview": "0.5.51",
6262
"react": "18.2.0",
6363
"react-csv": "2.2.2",
6464
"react-datepicker": "4.8.0",
6565
"react-dom": "18.2.0",
6666
"react-popper": "2.3.0",
67-
"react-select": "5.5.8",
67+
"react-select": "5.6.0",
6868
"react-window": "1.8.8",
6969
"zustand": "4.1.4"
7070
}

src/components/cellTypes/CalendarCell.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import React, { useState } from "react";
1+
import React, {
2+
DetailedHTMLProps,
3+
forwardRef,
4+
InputHTMLAttributes,
5+
useState,
6+
} from "react";
27
import { DateTime } from "luxon";
38
import DatePicker from "react-datepicker";
49
import { Portal } from "@mui/material";
@@ -7,6 +12,7 @@ import { CellComponentProps } from "cdm/ComponentsModel";
712
import { TableColumn } from "cdm/FolderModel";
813
import { ParseService } from "services/ParseService";
914
import { InputType } from "helpers/Constants";
15+
import { Platform } from "obsidian";
1016

1117
const CalendarCell = (calendarProps: CellComponentProps) => {
1218
const { defaultCell } = calendarProps;
@@ -51,7 +57,6 @@ const CalendarCell = (calendarProps: CellComponentProps) => {
5157
columnsInfo.getAllColumns(),
5258
configInfo.getLocalSettings()
5359
);
54-
setShowDatePicker(false);
5560
}
5661

5762
const CalendarContainer = (containerProps: any) => {
@@ -60,21 +65,31 @@ const CalendarCell = (calendarProps: CellComponentProps) => {
6065
);
6166
};
6267

63-
const onClickOutside = () => {
64-
setShowDatePicker(false);
68+
const closeEditCalendarCell = () => {
69+
// We need a delay to allow the click event of clearing the date to propagate
70+
setTimeout(() => {
71+
setShowDatePicker(false);
72+
}, 100);
6573
};
6674

75+
const ReactDatePickerInput = forwardRef<
76+
HTMLInputElement,
77+
DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>
78+
>((props, ref) => <input ref={ref} {...props} readOnly />);
79+
6780
return showDatePicker ? (
6881
<DatePicker
69-
dateFormat="yyyy-MM-dd"
82+
dateFormat={configInfo.getLocalSettings().date_format}
7083
selected={
7184
DateTime.isDateTime(calendarCell)
7285
? (calendarCell as unknown as DateTime).toJSDate()
7386
: null
7487
}
7588
onChange={handleCalendarChange}
7689
popperContainer={CalendarContainer}
77-
onClickOutside={onClickOutside}
90+
onClickOutside={closeEditCalendarCell}
91+
onCalendarClose={closeEditCalendarCell}
92+
customInput={Platform.isMobile ? <ReactDatePickerInput /> : null}
7893
autoFocus
7994
isClearable
8095
ariaLabelClose="Clear"

src/components/cellTypes/CalendarTimeCell.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import React, { useState } from "react";
1+
import React, {
2+
DetailedHTMLProps,
3+
forwardRef,
4+
InputHTMLAttributes,
5+
useState,
6+
} from "react";
27
import { DateTime } from "luxon";
38
import DatePicker from "react-datepicker";
49
import { Portal } from "@mui/material";
@@ -7,6 +12,7 @@ import { TableColumn } from "cdm/FolderModel";
712
import { ParseService } from "services/ParseService";
813
import { InputType } from "helpers/Constants";
914
import { c } from "helpers/StylesHelper";
15+
import { Platform } from "obsidian";
1016

1117
const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
1218
const { defaultCell } = calendarTimeProps;
@@ -52,7 +58,6 @@ const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
5258
columnsInfo.getAllColumns(),
5359
configInfo.getLocalSettings()
5460
);
55-
setShowDatePicker(false);
5661
}
5762

5863
const CalendarContainer = (containerProps: any) => {
@@ -61,6 +66,18 @@ const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
6166
);
6267
};
6368

69+
const closeEditCalendarTimeCell = () => {
70+
// We need a delay to allow the click event of clearing the date to propagate
71+
setTimeout(() => {
72+
setShowDatePicker(false);
73+
}, 100);
74+
};
75+
76+
const ReactDatePickerInput = forwardRef<
77+
HTMLInputElement,
78+
DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>
79+
>((props, ref) => <input ref={ref} {...props} readOnly />);
80+
6481
return showDatePicker &&
6582
(tableColumn.isMetadata === undefined || !tableColumn.isMetadata) ? (
6683
<DatePicker
@@ -72,7 +89,9 @@ const CalendarTimeCell = (calendarTimeProps: CellComponentProps) => {
7289
}
7390
onChange={handleCalendarChange}
7491
popperContainer={CalendarContainer}
75-
onClickOutside={() => setShowDatePicker(false)}
92+
onClickOutside={closeEditCalendarTimeCell}
93+
onCalendarClose={closeEditCalendarTimeCell}
94+
customInput={Platform.isMobile ? <ReactDatePickerInput /> : null}
7695
timeFormat="HH:mm"
7796
timeCaption="time"
7897
showTimeSelect

src/components/cellTypes/TagsCell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const TagsCell = (tagsProps: CellComponentProps) => {
8282
newValue: OnChangeValue<SelectValue, true>,
8383
actionMeta: ActionMeta<RowSelectOption>
8484
) => {
85-
const arrayTags = newValue.map((tag) => tag.value);
85+
const arrayTags = newValue.map((tag) => `${tag.value}`);
8686
const newCell = ParseService.parseRowToLiteral(
8787
tagsRow,
8888
tableColumn,
@@ -153,7 +153,7 @@ const TagsCell = (tagsProps: CellComponentProps) => {
153153
<div key={`key-${tag}`}>
154154
<Relationship
155155
key={`tags-${row.index}-${tableColumn.key}-${tag}`}
156-
value={tag}
156+
value={tag.toString()}
157157
backgroundColor={getColor(tag)}
158158
/>
159159
</div>

src/parsers/RowDatabaseFieldsToFile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function stringifyDbYaml(literal: Literal, level: number, localSettings: LocalSe
5858
else if (key) {
5959
literalBlock.push(`${" ".repeat(level)}${key}: ${ParseService.parseLiteral(literal, InputType.MARKDOWN, localSettings)}`);
6060
} else {
61-
literalBlock.push(`${" ".repeat(level)}- ${ParseService.parseLiteral(literal, InputType.MARKDOWN, localSettings)}`);
61+
literalBlock.push(`${" ".repeat(level)}- ${ParseService.parseLiteral(literal, InputType.MARKDOWN, { ...localSettings, frontmatter_quote_wrap: true })}`);
6262
}
6363
return literalBlock;
6464
}

styles.css

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");
2-
2+
/*****************
3+
* Plugin variables
4+
******************/
5+
body {
6+
--react-datepicker-navigation-height: 24px;
7+
--react-datepicker-navigation-width: 24px;
8+
}
9+
/*****************
10+
* Base
11+
******************/
312
.database-plugin__html {
413
box-sizing: border-box;
514
}
@@ -145,7 +154,7 @@ div.database-plugin__checkbox {
145154
color: currentColor;
146155
width: 1.15em;
147156
height: 1.15em;
148-
border: 0.15em solid currentColor;
157+
border: 0.05em solid currentColor;
149158
border-radius: 0.15em;
150159
transform: translateY(-0.075em);
151160

@@ -179,6 +188,10 @@ div.database-plugin__checkbox {
179188
outline-offset: max(2px, 0.15em);
180189
}
181190

191+
.database-plugin__checkbox input[type="checkbox"]:checked:after {
192+
background-color: var(--form-background);
193+
}
194+
182195
.database-plugin__md_cell {
183196
vertical-align: middle;
184197
}
@@ -671,9 +684,9 @@ div.database-plugin__checkbox {
671684
color: var(--text-on-accent);
672685
}
673686

674-
/*
687+
/*************************
675688
* React-datepicker styles
676-
*/
689+
**************************/
677690
.react-datepicker__year-read-view--down-arrow,
678691
.react-datepicker__month-read-view--down-arrow,
679692
.react-datepicker__month-year-read-view--down-arrow,
@@ -920,8 +933,8 @@ div.database-plugin__checkbox {
920933
padding: 0;
921934
border: none;
922935
z-index: 4;
923-
height: 32px;
924-
width: 32px;
936+
height: var(--react-datepicker-navigation-height);
937+
width: var(--react-datepicker-navigation-width);
925938
text-indent: -999em;
926939
overflow: hidden;
927940
}
@@ -1544,37 +1557,3 @@ div.database-plugin__checkbox {
15441557
padding: 5px 0;
15451558
clear: left;
15461559
}
1547-
1548-
.react-datepicker__portal {
1549-
position: fixed;
1550-
width: 100vw;
1551-
height: 100vh;
1552-
background-color: var(--background-primary);
1553-
left: 0;
1554-
top: 0;
1555-
justify-content: center;
1556-
align-items: center;
1557-
display: flex;
1558-
z-index: 4;
1559-
}
1560-
1561-
.react-datepicker__portal .react-datepicker__day-name,
1562-
.react-datepicker__portal .react-datepicker__day,
1563-
.react-datepicker__portal .react-datepicker__time-name {
1564-
width: 3rem;
1565-
line-height: 3rem;
1566-
}
1567-
1568-
@media (max-width: 400px), (max-height: 550px) {
1569-
.react-datepicker__portal .react-datepicker__day-name,
1570-
.react-datepicker__portal .react-datepicker__day,
1571-
.react-datepicker__portal .react-datepicker__time-name {
1572-
width: 2rem;
1573-
line-height: 2rem;
1574-
}
1575-
}
1576-
1577-
.react-datepicker__portal .react-datepicker__current-month,
1578-
.react-datepicker__portal .react-datepicker-time__header {
1579-
font-size: 1.44rem;
1580-
}

0 commit comments

Comments
 (0)