Skip to content

Commit

Permalink
Fix some type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
spaaaacccee committed Nov 21, 2024
1 parent aff9cc1 commit 5e779a2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
6 changes: 5 additions & 1 deletion client/src/components/generic/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ export function ManagedModal({
</Box>
</Popover>
) : (
<Modal open={isOpen} onClose={close} {...slotProps?.modal}>
<Modal
open={isOpen}
onClose={close as () => void}
{...slotProps?.modal}
>
<ModalAppBar onClose={close} {...ModalAppBarProps} />
{chi2}
</Modal>
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/script-editor/templates.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { TraceEvent } from "protocol/Trace";
import { FunctionTemplate } from "./FunctionTemplate";
import { EventTree } from "pages/tree.worker";

export type ShouldBreak = FunctionTemplate<
[number, TraceEvent, TraceEvent[], TraceEvent, TraceEvent[]],
[number, TraceEvent, TraceEvent[], EventTree | void, EventTree[] | void],
boolean
>;

Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useBreakpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function useBreakpoints(key?: string) {
event,
events,
trees[step]?.parent,
trees[step]?.children,
trees[step]?.children ?? [],
])
) {
return { result: "Script editor" };
Expand Down
19 changes: 16 additions & 3 deletions client/src/pages/TreePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const orientationOptions = {
};

type R = {
event: MouseEvent;
event: MouseEvent | TouchEvent;
node: string;
};

Expand Down Expand Up @@ -407,6 +407,19 @@ export function TreePage({ template: Page }: PageContentProps) {
}, [trace, setTrackedProperty]);

const [selection, setSelection] = useState<R>();

const { x, y } = selection
? selection.event instanceof MouseEvent
? {
x: selection.event.clientX,
y: selection.event.clientY,
}
: {
x: selection.event.touches?.[0]?.clientX,
y: selection.event.touches?.[0]?.clientY,
}
: { x: 0, y: 0 };

const [menuOpen, setMenuOpen] = useState(false);

const [mode, setMode] = useState<"tree" | "directed-graph">("tree");
Expand Down Expand Up @@ -491,8 +504,8 @@ export function TreePage({ template: Page }: PageContentProps) {
onClose={() => setMenuOpen(false)}
anchorReference="anchorPosition"
anchorPosition={{
left: selection?.event.clientX ?? 0,
top: selection?.event.clientY ?? 0,
left: x,
top: y,
}}
transformOrigin={{
horizontal: "left",
Expand Down

0 comments on commit 5e779a2

Please sign in to comment.