Skip to content

Commit 0ac99c8

Browse files
committed
Linting
1 parent f399a78 commit 0ac99c8

1 file changed

Lines changed: 37 additions & 24 deletions

File tree

src/components/SuggestionsDropdown.tsx

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,50 @@ export const SuggestionsDropdown: React.FunctionComponent<SuggestionsDropdownPro
3232
onSuggestionSelected(index);
3333
};
3434

35-
const handleMouseDown =
36-
(event: React.MouseEvent) => event.preventDefault();
35+
const handleMouseDown = (event: React.MouseEvent) => event.preventDefault();
36+
37+
const vw = Math.max(
38+
document.documentElement.clientWidth || 0,
39+
window.innerWidth || 0
40+
);
41+
const vh = Math.max(
42+
document.documentElement.clientHeight || 0,
43+
window.innerHeight || 0
44+
);
3745

38-
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
39-
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
40-
4146
const left = caret.left - textAreaRef.current.scrollLeft;
4247
const top = caret.top - textAreaRef.current.scrollTop;
4348

44-
const style = {} as React.CSSProperties;
45-
if (suggestionsAutoplace && top +
46-
textAreaRef.current.getBoundingClientRect().top +
47-
textAreaRef.current.ownerDocument.defaultView.pageYOffset +
48-
caret.lineHeight * 1.5 * suggestions.length > vh)
49+
const style: React.CSSProperties = {};
50+
if (
51+
suggestionsAutoplace &&
52+
top +
53+
textAreaRef.current.getBoundingClientRect().top +
54+
textAreaRef.current.ownerDocument.defaultView.pageYOffset +
55+
caret.lineHeight * 1.5 * suggestions.length >
56+
vh
57+
)
4958
style.bottom = textAreaRef.current.offsetHeight - caret.top;
50-
else
51-
style.top = top;
52-
53-
if (suggestionsAutoplace && left +
54-
textAreaRef.current.getBoundingClientRect().left +
55-
textAreaRef.current.ownerDocument.defaultView.pageXOffset +
56-
caret.lineHeight * 0.6666 * Math.max.apply(Math, suggestions.map(x => x.preview.toString().length)) > vw)
59+
else style.top = top;
60+
61+
if (
62+
suggestionsAutoplace &&
63+
left +
64+
textAreaRef.current.getBoundingClientRect().left +
65+
textAreaRef.current.ownerDocument.defaultView.pageXOffset +
66+
caret.lineHeight *
67+
0.6666 *
68+
Math.max.apply(
69+
Math,
70+
suggestions.map(x => x.preview.toString().length)
71+
) >
72+
vw
73+
)
5774
style.right = textAreaRef.current.offsetWidth - caret.left;
58-
else
59-
style.left = left;
60-
75+
else style.left = left;
76+
6177
return (
62-
<ul
63-
className={classNames("mde-suggestions", classes)}
64-
style={style}
65-
>
78+
<ul className={classNames("mde-suggestions", classes)} style={style}>
6679
{suggestions.map((s, i) => (
6780
<li
6881
onClick={handleSuggestionClick}

0 commit comments

Comments
 (0)