Skip to content

Commit

Permalink
fix: fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
IzStriker committed Dec 12, 2023
1 parent 6e4bcc1 commit e640c6c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/NotesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { remarkBreaks, sequentialNewlinesPlugin } from '../util/markdown';
import Button from './common/Button';
import Text from './common/Text';
import View from './common/View';
import { Tooltip, TooltipPosition, useTooltip } from './tooltips';
import { Tooltip, type TooltipPosition, useTooltip } from './tooltips';

const remarkPlugins = [sequentialNewlinesPlugin, remarkGfm, remarkBreaks];

Expand Down
24 changes: 16 additions & 8 deletions packages/desktop-client/src/components/tooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import {
type ReactNode,
type MouseEventHandler,
type MouseEvent,
type ContextType,
} from 'react';
import ReactDOM from 'react-dom';

import { css } from 'glamor';

import { type CSSProperties, styles, theme } from '../style';

export const IntersectionBoundary = createContext<any>(null);
export const IntersectionBoundary = createContext<RefObject<HTMLElement>>(null);

export function useTooltip() {
const [isOpen, setIsOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -53,17 +54,23 @@ type TooltipProps = {
forceLayout?: boolean;
forceTop?: number;
ignoreBoundary?: boolean;
targetRect?: any;
targetRect?: DOMRect;
offset?: number;
style?: CSSProperties;
width?: number;
children: ReactNode;
targetHeight?: number;
};
type MutableDomRect = {
top: number;
left: number;
width: number;
height: number;
};

export class Tooltip extends Component<TooltipProps> {
static contextType = IntersectionBoundary;
declare context: React.ContextType<typeof IntersectionBoundary>;
declare context: ContextType<typeof IntersectionBoundary>;
position: TooltipPosition;
contentRef: RefObject<HTMLDivElement>;
cleanup: () => void;
Expand Down Expand Up @@ -164,11 +171,11 @@ export class Tooltip extends Component<TooltipProps> {

if (
container.parentNode &&
container.parentNode.style.overflow === 'auto'
(container.parentNode as HTMLElement).style.overflow === 'auto'
) {
return container.parentNode;
return container.parentNode as HTMLElement;
}
return container;
return container as HTMLElement;
}

layout() {
Expand All @@ -179,9 +186,10 @@ export class Tooltip extends Component<TooltipProps> {
}

const box = contentEl.getBoundingClientRect();
const anchorEl = this.target.parentNode as any;
const anchorEl = this.target.parentNode as HTMLElement;

let anchorRect = targetRect || anchorEl.getBoundingClientRect();
let anchorRect: MutableDomRect =
targetRect || anchorEl.getBoundingClientRect();

// Copy it so we can mutate it
anchorRect = {
Expand Down

0 comments on commit e640c6c

Please sign in to comment.