1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Fix menu postiion, fix copy and paste in menu not working

This commit is contained in:
Andrew Kingston 2023-04-20 08:58:49 +01:00
parent 6bf6d15849
commit fe5ab61941
3 changed files with 8 additions and 9 deletions

View file

@ -42,7 +42,7 @@
<Menu>
<MenuItem
icon="Copy"
on:click={clipboard.actions.copyCell}
on:click={clipboard.actions.copy}
on:click={menu.actions.close}
>
Copy
@ -50,7 +50,7 @@
<MenuItem
icon="Paste"
disabled={$copiedCell == null}
on:click={clipboard.actions.pasteCell}
on:click={clipboard.actions.paste}
on:click={menu.actions.close}
>
Paste
@ -85,7 +85,7 @@
.menu {
position: absolute;
background: var(--cell-background);
border: var(--cell-border);
border: 1px solid var(--spectrum-global-color-gray-300);
width: 180px;
border-radius: 4px;
display: flex;

View file

@ -2,20 +2,17 @@ import { writable, get } from "svelte/store"
export const createStores = () => {
const copiedCell = writable(null)
const copiedRow = writable(null)
return {
copiedCell,
copiedRow,
}
}
export const deriveStores = context => {
const { copiedCell, copiedRow, focusedCellAPI } = context
const { copiedCell, focusedCellAPI } = context
const copy = () => {
copiedCell.set(get(focusedCellAPI)?.getValue())
copiedRow.set(null)
}
const paste = () => {

View file

@ -1,4 +1,5 @@
import { writable, get } from "svelte/store"
import { GutterWidth } from "../lib/constants"
export const createStores = () => {
const menu = writable({
@ -22,8 +23,9 @@ export const deriveStores = context => {
e.preventDefault()
focusedCellId.set(cellId)
menu.set({
left: e.clientX - $bounds.left + 44 + ($stickyColumn?.width || 0),
top: e.clientY - $bounds.top + $rowHeight + 4,
left:
e.clientX - $bounds.left + GutterWidth + ($stickyColumn?.width || 0),
top: e.clientY - $bounds.top + $rowHeight,
visible: true,
})
}