From d2858a2be4db3ccf4a47fb1708e962d6086e4cce Mon Sep 17 00:00:00 2001 From: David Stotijn Date: Sat, 26 Feb 2022 09:55:43 +0100 Subject: [PATCH] Fix input fields for key-value pair tables losing focus --- admin/src/lib/components/KeyValuePair.tsx | 38 ++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/admin/src/lib/components/KeyValuePair.tsx b/admin/src/lib/components/KeyValuePair.tsx index ce8167e..875c3cb 100644 --- a/admin/src/lib/components/KeyValuePair.tsx +++ b/admin/src/lib/components/KeyValuePair.tsx @@ -9,7 +9,6 @@ import { Table, TableBody, TableCell, - TableCellProps, TableContainer, TableHead, TableRow, @@ -74,19 +73,6 @@ export function KeyValuePairTable({ items, onChange, onDelete }: KeyValuePairTab setCopyConfOpen(false); }; - const baseCellStyle = { - "&:hover": { - cursor: "copy", - }, - }; - - const KeyTableCell = styled(TableCell)(() => (!onChange ? baseCellStyle : {})); - const ValueTableCell = styled(TableCell)(() => ({ - ...(!onChange && baseCellStyle), - width: "60%", - wordBreak: "break-all", - })); - return (
@@ -118,12 +104,19 @@ export function KeyValuePairTable({ items, onChange, onDelete }: KeyValuePairTab > {items.map(({ key, value }, idx) => ( - { !onChange && handleCellClick(e); }} + sx={{ + ...(!onChange && { + "&:hover": { + cursor: "copy", + }, + }), + }} > {!onChange && {key}} {onChange && ( @@ -137,11 +130,20 @@ export function KeyValuePairTable({ items, onChange, onDelete }: KeyValuePairTab }} /> )} - - + { !onChange && handleCellClick(e); }} + sx={{ + width: "60%", + wordBreak: "break-all", + ...(!onChange && { + "&:hover": { + cursor: "copy", + }, + }), + }} > {!onChange && value} {onChange && ( @@ -155,7 +157,7 @@ export function KeyValuePairTable({ items, onChange, onDelete }: KeyValuePairTab }} /> )} - + {onDelete && (