Skip to content

Commit

Permalink
fix: slash menu scroll behavior (#1386)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone authored Jun 19, 2024
1 parent 097532e commit cc6a3eb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions packages/crepe/src/feature/block-edit/menu/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,20 @@ export const menuComponent: Component<MenuProps> = ({
}, [])

const scrollToIndex = useCallback((index: number) => {
host
const target = host
.current
.querySelector(`[data-index="${index}"]`)
?.scrollIntoView({
behavior: 'smooth',
block: 'end',
})
.querySelector<HTMLElement>(`[data-index="${index}"]`)
const scrollRoot = host.current.querySelector<HTMLElement>('.menu-groups')

if (!target || !scrollRoot)
return

scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop

// target?.scrollIntoView({
// behavior: 'smooth',
// block: 'end',
// })
}, [])

const runByIndex = useCallback((index: number) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/crepe/src/theme/common/block-edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
padding: 0 12px 12px;
max-height: 420px;
overflow: auto;
overscroll-behavior: contain;
scroll-behavior: smooth;

.menu-group {
h6 {
Expand Down
1 change: 0 additions & 1 deletion packages/crepe/src/theme/common/cursor.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
.ProseMirror-gapcursor:after {
box-sizing: border-box;
border-top: 1px solid var(--crepe-color-on-background);
top: -40px;
}
}

0 comments on commit cc6a3eb

Please sign in to comment.