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

Commit 87f25cc

Browse files
committed
improving add row
1 parent af27957 commit 87f25cc

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

src/components/Table.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,18 @@ export function Table(tableData: TableDataType) {
250250
const [rowTemplateState, setRowTemplateState] = React.useState(
251251
view.diskConfig.yaml.config.current_row_template
252252
);
253-
const rowTemplatesOptions = get_tfiles_from_folder(
254-
view.diskConfig.yaml.config.row_templates_folder
255-
).map((tfile) => {
256-
return {
257-
value: tfile.path,
258-
label: tfile.path,
259-
};
260-
});
253+
const rowTemplatesOptions = React.useMemo(
254+
() =>
255+
get_tfiles_from_folder(
256+
view.diskConfig.yaml.config.row_templates_folder
257+
).map((tfile) => {
258+
return {
259+
value: tfile.path,
260+
label: tfile.path,
261+
};
262+
}),
263+
[]
264+
);
261265

262266
function handleChangeRowTemplate(
263267
newValue: OnChangeValue<RowTemplateOption, false>,
@@ -432,6 +436,7 @@ export function Table(tableData: TableDataType) {
432436
<div
433437
key={`div-add-row-cell-padding-left`}
434438
className={`${c("td padding-left")}`}
439+
style={{ minWidth: "17rem" }}
435440
>
436441
<Select
437442
styles={CustomTemplateSelectorStyles}
@@ -443,10 +448,11 @@ export function Table(tableData: TableDataType) {
443448
isClearable={true}
444449
isMulti={false}
445450
onChange={handleChangeRowTemplate}
446-
defaultValue={{ label: "Choose a Template", value: "None" }}
451+
placeholder={<div>Without template. Select one to use...</div>}
447452
menuPortalTarget={document.body}
448453
menuShouldBlockScroll={true}
449454
isSearchable
455+
menuPlacement="top"
450456
/>
451457
</div>
452458
{/* ENDS NEW ROW */}

src/components/styles/RowTemplateStyles.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ const CustomTemplateSelectorStyles: StylesConfig<any, true, GroupBase<any>> = {
99
width: 'auto',
1010
}
1111
},
12+
placeholder: (styles) => {
13+
return {
14+
...styles,
15+
fontSize: '12px',
16+
textAlign: 'left',
17+
minWidth: '17rem',
18+
}
19+
}
1220
}
1321

1422
export default CustomTemplateSelectorStyles;

styles.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ div.database-plugin__checkbox {
294294
.database-plugin__add-row .svg-icon:hover {
295295
background-color: var(--background-secondary);
296296
color: var(--text-accent-hover);
297-
padding: 0.6rem;
297+
padding: 0.3rem;
298298
}
299299

300300
.database-plugin__add-row .database-plugin__td {
@@ -317,7 +317,6 @@ div.database-plugin__checkbox {
317317
.database-plugin__th:hover {
318318
background-color: var(--background-secondary);
319319
color: var(--text-normal);
320-
padding: 0.3rem;
321320
}
322321

323322
.database-plugin__th-content {

0 commit comments

Comments
 (0)