fix(dashboard): Allow using enter key to create newline in Textarea (#9913)

* fix(dashboard):Allow using enter key to create newline in Textarea

* update scheam file
This commit is contained in:
Kasper Fabricius Kristensen
2024-11-05 08:54:28 +01:00
committed by GitHub
parent c0368cca28
commit d19d7a66ff
5 changed files with 45 additions and 8 deletions

View File

@@ -14,6 +14,13 @@ export const KeyboundForm = React.forwardRef<
const handleKeyDown = (event: React.KeyboardEvent<HTMLFormElement>) => {
if (event.key === "Enter") {
if (
event.target instanceof HTMLTextAreaElement &&
!(event.metaKey || event.ctrlKey)
) {
return
}
event.preventDefault()
if (event.metaKey || event.ctrlKey) {

View File

@@ -1555,6 +1555,26 @@
],
"additionalProperties": false
},
"edit": {
"type": "object",
"properties": {
"header": {
"type": "string"
},
"description": {
"type": "string"
},
"successToast": {
"type": "string"
}
},
"required": [
"header",
"description",
"successToast"
],
"additionalProperties": false
},
"create": {
"type": "object",
"properties": {
@@ -1894,9 +1914,6 @@
"attributes": {
"type": "string"
},
"editProduct": {
"type": "string"
},
"editAttributes": {
"type": "string"
},
@@ -2667,13 +2684,13 @@
"required": [
"domain",
"list",
"edit",
"create",
"export",
"import",
"deleteWarning",
"variants",
"attributes",
"editProduct",
"editAttributes",
"editOptions",
"editPrices",

View File

@@ -380,6 +380,11 @@
"list": {
"noRecordsMessage": "Create your first product to start selling."
},
"edit": {
"header": "Edit Product",
"description": "Edit the product details.",
"successToast": "Product {{title}} was successfully updated."
},
"create": {
"header": "General",
"tabs": {
@@ -462,7 +467,6 @@
"deleteWarning": "You are about to delete the product {{title}}. This action cannot be undone.",
"variants": "Variants",
"attributes": "Attributes",
"editProduct": "Edit Product",
"editAttributes": "Edit Attributes",
"editOptions": "Edit Options",
"editPrices": "Edit prices",

View File

@@ -1,4 +1,4 @@
import { Button, Input, Select, Text, Textarea } from "@medusajs/ui"
import { Button, Input, Select, Text, Textarea, toast } from "@medusajs/ui"
import { useTranslation } from "react-i18next"
import * as zod from "zod"
@@ -69,9 +69,15 @@ export const EditProductForm = ({ product }: EditProductFormProps) => {
...nullableData,
},
{
onSuccess: () => {
onSuccess: ({ product }) => {
toast.success(
t("products.edit.successToast", { title: product.title })
)
handleSuccess()
},
onError: (e) => {
toast.error(e.message)
},
}
)
})

View File

@@ -23,8 +23,11 @@ export const ProductEdit = () => {
<RouteDrawer>
<RouteDrawer.Header>
<RouteDrawer.Title asChild>
<Heading>{t("products.editProduct")}</Heading>
<Heading>{t("products.edit.header")}</Heading>
</RouteDrawer.Title>
<RouteDrawer.Description className="sr-only">
{t("products.edit.description")}
</RouteDrawer.Description>
</RouteDrawer.Header>
{!isLoading && product && <EditProductForm product={product} />}
</RouteDrawer>