[cm6] Improve alignment of review panel elements (#12710)
* Use a block widget for top padding * Update review panel positions when the editor geometry changes * Remove editorPaddingTop from position calculations * Recalculate review panel on start adding comment * Assert on line content rather than index * Use broadcastChange * Keep focus in the editor when opening the review panel * debounce broadcastChange * Set CULL_AFTER to Infinity GitOrigin-RevId: a8d7b8967736a9164b5264eeaadf334c15ec95ce
This commit is contained in:
+11
-12
@@ -13,7 +13,7 @@ import { debounce } from 'lodash'
|
||||
|
||||
// With less than this number of entries, don't bother culling to avoid
|
||||
// little UI jumps when scrolling.
|
||||
const CULL_AFTER = 100
|
||||
const CULL_AFTER = Infinity // Note: was 100 but couldn't scroll to see items outside the viewport
|
||||
|
||||
export const dispatchEditorEvent = (type: string, payload?: unknown) => {
|
||||
window.setTimeout(() => {
|
||||
@@ -291,24 +291,25 @@ export const createChangeManager = (
|
||||
acceptChanges(payload)
|
||||
view.dispatch(buildChangeMarkers())
|
||||
broadcastChange()
|
||||
dispatchFocusChangedEvent(view.state)
|
||||
break
|
||||
}
|
||||
|
||||
case 'changes:reject': {
|
||||
view.dispatch(rejectChanges(payload))
|
||||
dispatchFocusChangedEvent(view.state)
|
||||
broadcastChange()
|
||||
break
|
||||
}
|
||||
|
||||
case 'comment:select_line': {
|
||||
selectCurrentLine()
|
||||
broadcastChange()
|
||||
break
|
||||
}
|
||||
|
||||
case 'comment:add': {
|
||||
addComment(payload.offset, payload.length, payload.threadId)
|
||||
collapseSelection()
|
||||
broadcastChange()
|
||||
break
|
||||
}
|
||||
|
||||
@@ -329,9 +330,6 @@ export const createChangeManager = (
|
||||
case 'loaded_threads': {
|
||||
view.dispatch(buildChangeMarkers())
|
||||
broadcastChange()
|
||||
window.setTimeout(() => {
|
||||
dispatchFocusChangedEvent(view.state)
|
||||
}, 0)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -359,12 +357,9 @@ export const createChangeManager = (
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const broadcastChange = () => {
|
||||
const broadcastChange = debounce(() => {
|
||||
dispatchEditorEvent('track-changes:changed')
|
||||
}
|
||||
}, 50)
|
||||
|
||||
/**
|
||||
* When the editor content, focus, size, viewport or selection changes,
|
||||
@@ -450,9 +445,13 @@ export const createChangeManager = (
|
||||
return {
|
||||
initialize() {
|
||||
addListeners()
|
||||
dispatchEditorEvent('track-changes:changed')
|
||||
broadcastChange()
|
||||
},
|
||||
handleUpdate(update: ViewUpdate) {
|
||||
if (update.geometryChanged && !update.docChanged) {
|
||||
broadcastChange()
|
||||
}
|
||||
|
||||
if (updateSetsVerticalOverflow(update)) {
|
||||
ignoreGeometryChangesUntil = Date.now() + 50 // ignore changes for 50ms
|
||||
} else if (
|
||||
|
||||
Reference in New Issue
Block a user