Skip to content

Commit e8b750e

Browse files
authored
ENG-1166 - allow setting open state for embed in query blocks (#618)
1 parent 5962c3c commit e8b750e

3 files changed

Lines changed: 27 additions & 20 deletions

File tree

apps/roam/src/components/results-view/Kanban.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ const BlockEmbed = ({ uid, viewValue }: { uid: string; viewValue: string }) => {
3838
window.roamAlphaAPI.ui.components.renderBlock({
3939
uid,
4040
el,
41-
// "open?": open, // waiting for roamAlphaAPI to add a open/close to renderBlock
41+
// @ts-expect-error - add to roamjs-components
42+
// eslint-disable-next-line @typescript-eslint/naming-convention
43+
"open?": open,
4244
});
4345
}
4446
}, [uid, open, contentRef]);
4547
return (
46-
<div ref={contentRef} className={!!title ? "page-embed" : "block-embed"} />
48+
<div ref={contentRef} className={title ? "page-embed" : "block-embed"} />
4749
);
4850
};
4951

apps/roam/src/components/results-view/ResultsTable.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,14 @@ export const CellEmbed = ({
168168
window.roamAlphaAPI.ui.components.renderBlock({
169169
uid,
170170
el,
171-
// "open?": open, // waiting for roamAlphaAPI to add a open/close to renderBlock
171+
// @ts-expect-error - add to roamjs-components
172+
// eslint-disable-next-line @typescript-eslint/naming-convention
173+
"open?": open,
172174
});
173175
}
174-
}, [contentRef]);
176+
}, [contentRef, uid, viewValue]);
175177
return (
176-
<div className="roamjs-query-embed">
177-
<div
178-
ref={contentRef}
179-
className={!!title ? "page-embed" : "block-embed"}
180-
/>
181-
</div>
178+
<div ref={contentRef} className={title ? "page-embed" : "block-embed"} />
182179
);
183180
};
184181

apps/roam/src/components/results-view/ResultsView.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ import { Inputs } from "./Inputs";
5252
const VIEWS: Record<string, { value: boolean }> = {
5353
link: { value: false },
5454
plain: { value: false },
55-
embed: { value: false },
55+
embed: { value: true },
5656
alias: { value: true },
5757
};
5858

59-
const EMBED_FOLD_VALUES = ["default", "open", "closed"]; // waiting for roamAlphaAPI to add a open/close to renderBlock
59+
const EMBED_FOLD_VALUES = ["default", "open", "closed"];
6060

6161
type EnglishQueryPart = { text: string; clickId?: string };
6262

@@ -1078,27 +1078,35 @@ const ResultsView: ResultsViewComponent = ({
10781078
}
10791079
/>
10801080
)}
1081-
{/* {mode === "embed" && (
1081+
{mode === "embed" && (
10821082
<div className="flex items-center">
10831083
<MenuItemSelect
10841084
className="roamjs-view-select"
10851085
items={EMBED_FOLD_VALUES}
1086-
activeItem={
1087-
!!value ? value : EMBED_FOLD_VALUES[0]
1088-
}
1089-
onItemSelect={(value) => {
1090-
onViewChange({ mode, column, value }, i);
1086+
activeItem={value || EMBED_FOLD_VALUES[0]}
1087+
onItemSelect={(nextValue) => {
1088+
onViewChange(
1089+
{
1090+
mode,
1091+
column,
1092+
value:
1093+
nextValue === "default"
1094+
? ""
1095+
: nextValue,
1096+
},
1097+
i,
1098+
);
10911099
}}
10921100
/>
10931101
<Tooltip content="Initial folded state">
10941102
<Icon
10951103
icon="info-sign"
10961104
iconSize={12}
1097-
className="opacity-80 ml-2 align-middle"
1105+
className="ml-2 align-middle opacity-80"
10981106
/>
10991107
</Tooltip>
11001108
</div>
1101-
)} */}
1109+
)}
11021110
</td>
11031111
)}
11041112
</tr>

0 commit comments

Comments
 (0)