1
0
Fork 0
mirror of synced 2024-09-20 11:27:56 +12:00

Prevent pasting in the new row component

This commit is contained in:
Andrew Kingston 2024-06-26 14:52:25 +01:00
parent 3fc6026f5c
commit 6e9939f441
No known key found for this signature in database

View file

@ -1,6 +1,7 @@
import { derived, writable, get } from "svelte/store"
import { Helpers } from "@budibase/bbui"
import { parseCellID, getCellID } from "../lib/utils"
import { NewRowID } from "../lib/constants"
export const createStores = () => {
const clipboard = writable({
@ -13,7 +14,8 @@ export const createStores = () => {
}
export const deriveStores = context => {
const { clipboard, focusedCellAPI, selectedCellCount, config } = context
const { clipboard, focusedCellAPI, selectedCellCount, config, focusedRowId } =
context
// Derive whether or not we're able to copy
const copyAllowed = derived(focusedCellAPI, $focusedCellAPI => {
@ -22,12 +24,19 @@ export const deriveStores = context => {
// Derive whether or not we're able to paste
const pasteAllowed = derived(
[clipboard, focusedCellAPI, selectedCellCount, config],
([$clipboard, $focusedCellAPI, $selectedCellCount, $config]) => {
[clipboard, focusedCellAPI, selectedCellCount, config, focusedRowId],
([
$clipboard,
$focusedCellAPI,
$selectedCellCount,
$config,
$focusedRowId,
]) => {
if (
$clipboard.value == null ||
!$config.canEditRows ||
!$focusedCellAPI
!$focusedCellAPI ||
$focusedRowId === NewRowID
) {
return false
}