Skip to content

Commit 5600a73

Browse files
committed
Ensure tabstops are properly scrolled into view
1 parent 44a5445 commit 5600a73

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

package/src/extensions/autocomplete/tooltip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,20 @@ const autoComplete =
172172
insertText(editor, insert, start, end, tabStops[0], tabStops[1])
173173

174174
if (l > 2) {
175+
if (!stops) addOverlay(editor, tabStopsContainer)
175176
stops = tabStops
176177
activeStop = 0
177178
prevLength = editor.value.length
178179
updateStops()
179180
currentSelection = getSelection()
180-
if (!tabStopsContainer.parentNode) addOverlay(editor, tabStopsContainer)
181181
}
182182
cursor!.scrollIntoView()
183183
}
184184

185185
const moveActiveStop = (offset: number) => {
186186
activeStop += offset
187187
setSelection(editor, stops![activeStop], stops![activeStop + 1])
188-
cursor!.scrollIntoView()
188+
tabStopsContainer.children[activeStop / 2].scrollIntoView({ block: "nearest" })
189189
}
190190

191191
const clearStops = () => {

react-package/src/extensions/autocomplete/tooltip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,20 @@ const useAutoComplete = (editor: PrismEditor, config: AutoCompleteConfig) => {
180180
insertText(editor, insert, start, end, tabStops[0], tabStops[1])
181181

182182
if (l > 2) {
183+
if (!stops) addOverlay(editor, tabStopsContainer)
183184
stops = tabStops
184185
activeStop = 0
185186
prevLength = editor.value.length
186187
updateStops()
187188
currentSelection = getSelection()
188-
if (!tabStopsContainer.parentNode) addOverlay(editor, tabStopsContainer)
189189
}
190190
cursor!.scrollIntoView()
191191
}
192192

193193
const moveActiveStop = (offset: number) => {
194194
activeStop += offset
195195
setSelection(editor, stops![activeStop], stops![activeStop + 1])
196-
cursor!.scrollIntoView()
196+
tabStopsContainer.children[activeStop / 2].scrollIntoView({ block: "nearest" })
197197
}
198198

199199
const clearStops = () => {

solid-package/src/extensions/autocomplete/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ const autoComplete =
190190
const moveActiveStop = (offset: number) => {
191191
activeStop += offset
192192
setSelection(editor, stops![activeStop], stops![activeStop + 1])
193-
cursor!.scrollIntoView()
193+
tabStopsContainer.children[activeStop / 2].scrollIntoView({ block: "nearest" })
194194
}
195195

196196
const clearStops = () => {

0 commit comments

Comments
 (0)