Skip to content

Commit 6b200c7

Browse files
committed
Fix scroll into view of tags in pip window
1 parent 8e3c8c5 commit 6b200c7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/common/components/TextInput/TagList/TagList.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ export const getNewTagPhrase = (tag: string) =>
1313

1414
export let isUserSelectingTag = false;
1515

16-
type Props = SuggestionProps<PlainTag, MentionNodeAttrs>;
16+
export type TagListProps = SuggestionProps<PlainTag, MentionNodeAttrs> & {
17+
parentWindow: Window;
18+
};
1719

1820
export type TagListRef = {
1921
onKeyDown: (data: SuggestionKeyDownProps) => boolean;
2022
};
2123

22-
export const TagList = forwardRef<TagListRef, Props>((props, ref) => {
23-
const { items } = props;
24+
export const TagList = forwardRef<TagListRef, TagListProps>((props, ref) => {
25+
const { items, parentWindow } = props;
2426
const [selectedIndex, setSelectedIndex] = useState(1);
2527

2628
useEffect(() => {
@@ -51,7 +53,7 @@ export const TagList = forwardRef<TagListRef, Props>((props, ref) => {
5153
};
5254

5355
const scrollIntoView = (index: number) => {
54-
const itemElement = document.querySelector(
56+
const itemElement = parentWindow.document.querySelector(
5557
`[data-selector=tags-dropdown]>:nth-child(${index + 1})`,
5658
);
5759
itemElement?.scrollIntoView({

src/common/components/TextInput/TextInput.config.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ export const getExtensions = (settings: Settings) => {
131131
return {
132132
onStart: (props) => {
133133
component = new ReactRenderer(TagList, {
134-
props,
134+
props: {
135+
...props,
136+
parentWindow,
137+
},
135138
editor: props.editor,
136139
});
137140

0 commit comments

Comments
 (0)