Skip to content

Commit e52fddb

Browse files
maparentmdroidian
andauthored
ENG-1642 Discourse context overlay gets re-triggered every hover in a query block when view is render (#989)
* ENG-1642 Memoize results table to avoid redraws * spurious includes * Refactor ResultsView component to simplify menu icon visibility (#1006) - Removed state management for revealMenuIcons and associated mouse event handlers. - Introduced a new className for menu icons to control visibility based on interface settings and hover state. - Updated CSS to manage menu icon display logic, enhancing user experience by streamlining the interface. This change improves the clarity and maintainability of the ResultsView component. * remove memo --------- Co-authored-by: Michael Gartner <mclicks@gmail.com>
1 parent 5fd1f73 commit e52fddb

3 files changed

Lines changed: 24 additions & 15 deletions

File tree

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,7 @@ export const CellEmbed = ({
160160
);
161161
};
162162

163-
export const CellRender = ({
164-
content,
165-
uid,
166-
}: {
167-
content: string;
168-
uid: string;
169-
}) => {
163+
const CellRender = ({ content, uid }: { content: string; uid: string }) => {
170164
const isPage = !!getPageTitleByPageUid(uid);
171165
const displayString = isPage ? `[[${content}]]` : content;
172166

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,7 @@ const ResultsView: ResultsViewComponent = ({
330330
settings.showSearchFilter,
331331
);
332332
const [showInterface, setShowInterface] = useState(settings.showInterface);
333-
const [revealMenuIcons, setRevealMenuIcons] = useState(false);
334333
const [showInputs, setShowInputs] = useState(settings.showInputs);
335-
const hideMenuIcons = hideMenu || (!revealMenuIcons && !showInterface);
336334
const [showAlias, setShowAlias] = useState(settings.showAlias);
337335
const [isEditAlias, setIsEditAlias] = useState(false);
338336
const [alias, setAlias] = useState(settings.alias);
@@ -452,13 +450,19 @@ const ResultsView: ResultsViewComponent = ({
452450
() => views.filter((view) => view.mode !== "hidden").length,
453451
[views],
454452
);
453+
const menuIconClassName = [
454+
"roamjs-query-menu-icons",
455+
hideMenu
456+
? ""
457+
: showInterface
458+
? "roamjs-query-menu-icons-visible"
459+
: "roamjs-query-menu-icons-hover",
460+
].join(" ");
455461

456462
return (
457463
<div
458464
className={`roamjs-query-results-view relative w-full mode-${layout.mode}`}
459465
ref={containerRef}
460-
onMouseEnter={() => setRevealMenuIcons(true)}
461-
onMouseLeave={() => setRevealMenuIcons(false)}
462466
>
463467
{showAlias && (
464468
<div
@@ -580,10 +584,7 @@ const ResultsView: ResultsViewComponent = ({
580584
/>
581585
{header}
582586
<div className="relative">
583-
<div
584-
style={hideMenuIcons ? { display: "none" } : {}}
585-
className="absolute right-0 z-10 p-1"
586-
>
587+
<div className={menuIconClassName}>
587588
{onRefresh && (
588589
<Tooltip content={"Refresh Results"}>
589590
<Button icon={"refresh"} minimal onClick={() => onRefresh()} />

apps/roam/src/styles/styles.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@
7575
padding: 8px;
7676
}
7777

78+
.roamjs-query-menu-icons {
79+
position: absolute;
80+
right: 0;
81+
z-index: 10;
82+
display: none;
83+
padding: 4px;
84+
}
85+
86+
.roamjs-query-menu-icons.roamjs-query-menu-icons-visible,
87+
.roamjs-query-results-view:hover
88+
.roamjs-query-menu-icons.roamjs-query-menu-icons-hover {
89+
display: block;
90+
}
91+
7892
/* Solves dot-tags (.#sticky, .#meeting) flashing on when hovering anywhere on the
7993
Query Table. Roam shows them via .rm-block__self:hover and the entire table lives
8094
in one block, so we scope visibility to the individual cell instead. */

0 commit comments

Comments
 (0)