diff --git a/packages/module/patternfly-docs/content/examples/Basic.tsx b/packages/module/patternfly-docs/content/examples/Basic.tsx index 513eede..2b47c25 100644 --- a/packages/module/patternfly-docs/content/examples/Basic.tsx +++ b/packages/module/patternfly-docs/content/examples/Basic.tsx @@ -40,34 +40,34 @@ export const DeleteModalBasic: React.FunctionComponent = () => { handleModalRecoverableToggle(undefined)} deleteVariant="easily-recoverable" isOpen={isModalRecoverableOpen} onClose={handleModalRecoverableToggle} > - User group 123 will be deleted. + The item-name item will be deleted. handleModalDestructiveToggle(undefined)} deleteVariant="destructive" isOpen={isModalDestructiveOpen} onClose={handleModalDestructiveToggle} > - Experiment cool-exp will be deleted. + The item-name item will be deleted. [Brief sentence describing consequence of action]. handleModalExtraDestructiveToggle(undefined)} deleteVariant="extra-destructive" isOpen={isModalExtraDestructiveOpen} onClose={handleModalExtraDestructiveToggle} > - Project RedHatAwesome will be deleted. + The item-name item will be deleted. [Brief sentence describing consequence of action]. ); diff --git a/packages/module/patternfly-docs/generated/extensions/ai-infra-ui-components/react.js b/packages/module/patternfly-docs/generated/extensions/ai-infra-ui-components/react.js index d06d9a3..11d4e4d 100644 --- a/packages/module/patternfly-docs/generated/extensions/ai-infra-ui-components/react.js +++ b/packages/module/patternfly-docs/generated/extensions/ai-infra-ui-components/react.js @@ -121,11 +121,11 @@ pageData.liveContext = { }; pageData.examples = { 'Example': props => - {\n const [isModalRecoverableOpen, setIsModalRecoverableOpen] = React.useState(false);\n const [isModalDestructiveOpen, setIsModalDestructiveOpen] = React.useState(false);\n const [isModalExtraDestructiveOpen, setIsModalExtraDestructiveOpen] = React.useState(false);\n\n const handleModalRecoverableToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalRecoverableOpen(!isModalRecoverableOpen);\n };\n\n const handleModalDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalDestructiveOpen(!isModalDestructiveOpen);\n };\n\n const handleModalExtraDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalExtraDestructiveOpen(!isModalExtraDestructiveOpen);\n };\n\n return (\n <>\n \n \n \n \n \n \n \n \n \n \n \n\n handleModalRecoverableToggle(undefined)}\n deleteVariant=\"easily-recoverable\"\n isOpen={isModalRecoverableOpen}\n onClose={handleModalRecoverableToggle}\n >\n User group 123 will be deleted.\n \n handleModalDestructiveToggle(undefined)}\n deleteVariant=\"destructive\"\n isOpen={isModalDestructiveOpen}\n onClose={handleModalDestructiveToggle}\n >\n Experiment cool-exp will be deleted.\n \n handleModalExtraDestructiveToggle(undefined)}\n deleteVariant=\"extra-destructive\"\n isOpen={isModalExtraDestructiveOpen}\n onClose={handleModalExtraDestructiveToggle}\n >\n Project RedHatAwesome will be deleted.\n \n \n );\n};\n","title":"Example","lang":"js","className":""}}> + {\n const [isModalRecoverableOpen, setIsModalRecoverableOpen] = React.useState(false);\n const [isModalDestructiveOpen, setIsModalDestructiveOpen] = React.useState(false);\n const [isModalExtraDestructiveOpen, setIsModalExtraDestructiveOpen] = React.useState(false);\n\n const handleModalRecoverableToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalRecoverableOpen(!isModalRecoverableOpen);\n };\n\n const handleModalDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalDestructiveOpen(!isModalDestructiveOpen);\n };\n\n const handleModalExtraDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalExtraDestructiveOpen(!isModalExtraDestructiveOpen);\n };\n\n return (\n <>\n \n \n \n \n \n \n \n \n \n \n \n\n handleModalRecoverableToggle(undefined)}\n deleteVariant=\"easily-recoverable\"\n isOpen={isModalRecoverableOpen}\n onClose={handleModalRecoverableToggle}\n >\n The item-name item will be deleted.\n \n handleModalDestructiveToggle(undefined)}\n deleteVariant=\"destructive\"\n isOpen={isModalDestructiveOpen}\n onClose={handleModalDestructiveToggle}\n >\n The item-name item will be deleted. [Brief sentence describing consequence of action].\n \n handleModalExtraDestructiveToggle(undefined)}\n deleteVariant=\"extra-destructive\"\n isOpen={isModalExtraDestructiveOpen}\n onClose={handleModalExtraDestructiveToggle}\n >\n The item-name item will be deleted. [Brief sentence describing consequence of action].\n \n \n );\n};\n","title":"Example","lang":"js","className":""}}> , 'Fullscreen example': props => - {\n const [isModalRecoverableOpen, setIsModalRecoverableOpen] = React.useState(false);\n const [isModalDestructiveOpen, setIsModalDestructiveOpen] = React.useState(false);\n const [isModalExtraDestructiveOpen, setIsModalExtraDestructiveOpen] = React.useState(false);\n\n const handleModalRecoverableToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalRecoverableOpen(!isModalRecoverableOpen);\n };\n\n const handleModalDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalDestructiveOpen(!isModalDestructiveOpen);\n };\n\n const handleModalExtraDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalExtraDestructiveOpen(!isModalExtraDestructiveOpen);\n };\n\n return (\n <>\n \n \n \n \n \n \n \n \n \n \n \n\n handleModalRecoverableToggle(undefined)}\n deleteVariant=\"easily-recoverable\"\n isOpen={isModalRecoverableOpen}\n onClose={handleModalRecoverableToggle}\n >\n User group 123 will be deleted.\n \n handleModalDestructiveToggle(undefined)}\n deleteVariant=\"destructive\"\n isOpen={isModalDestructiveOpen}\n onClose={handleModalDestructiveToggle}\n >\n Experiment cool-exp will be deleted.\n \n handleModalExtraDestructiveToggle(undefined)}\n deleteVariant=\"extra-destructive\"\n isOpen={isModalExtraDestructiveOpen}\n onClose={handleModalExtraDestructiveToggle}\n >\n Project RedHatAwesome will be deleted.\n \n \n );\n};\n","title":"Fullscreen example","lang":"js","isFullscreen":true,"className":""}}> + {\n const [isModalRecoverableOpen, setIsModalRecoverableOpen] = React.useState(false);\n const [isModalDestructiveOpen, setIsModalDestructiveOpen] = React.useState(false);\n const [isModalExtraDestructiveOpen, setIsModalExtraDestructiveOpen] = React.useState(false);\n\n const handleModalRecoverableToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalRecoverableOpen(!isModalRecoverableOpen);\n };\n\n const handleModalDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalDestructiveOpen(!isModalDestructiveOpen);\n };\n\n const handleModalExtraDestructiveToggle = (_event: KeyboardEvent | React.MouseEvent | undefined) => {\n setIsModalExtraDestructiveOpen(!isModalExtraDestructiveOpen);\n };\n\n return (\n <>\n \n \n \n \n \n \n \n \n \n \n \n\n handleModalRecoverableToggle(undefined)}\n deleteVariant=\"easily-recoverable\"\n isOpen={isModalRecoverableOpen}\n onClose={handleModalRecoverableToggle}\n >\n The item-name item will be deleted.\n \n handleModalDestructiveToggle(undefined)}\n deleteVariant=\"destructive\"\n isOpen={isModalDestructiveOpen}\n onClose={handleModalDestructiveToggle}\n >\n The item-name item will be deleted. [Brief sentence describing consequence of action].\n \n handleModalExtraDestructiveToggle(undefined)}\n deleteVariant=\"extra-destructive\"\n isOpen={isModalExtraDestructiveOpen}\n onClose={handleModalExtraDestructiveToggle}\n >\n The item-name item will be deleted. [Brief sentence describing consequence of action].\n \n \n );\n};\n","title":"Fullscreen example","lang":"js","isFullscreen":true,"className":""}}> , 'DeleteModal implementation': props => diff --git a/packages/module/src/DeleteModal/DeleteModal.tsx b/packages/module/src/DeleteModal/DeleteModal.tsx index 1099ff0..aa15d28 100644 --- a/packages/module/src/DeleteModal/DeleteModal.tsx +++ b/packages/module/src/DeleteModal/DeleteModal.tsx @@ -67,17 +67,17 @@ export const DeleteModal: React.FunctionComponent = ({ isOpen, ...props }: DeleteModalProps) => { - const [confirmationText, setConfirmationText] = React.useState(''); - const confirmed = deleteVariant === 'extra-destructive' ? confirmationText.trim() === deleteName : true; + const [inputValue, setInputValue] = React.useState(''); + const confirmed = deleteVariant === 'extra-destructive' ? inputValue.trim() === deleteName : true; React.useEffect(() => { if (!isOpen) { - setConfirmationText(''); + setInputValue(''); } }, [isOpen]); return ( - + @@ -85,13 +85,13 @@ export const DeleteModal: React.FunctionComponent = ({ {deleteVariant === 'extra-destructive' && ( - {confirmationMessage(deleteName)} + {confirmationMessage(deleteName)} setConfirmationText(value)} + aria-labelledby="confirmation-message" + value={inputValue} + onChange={(_e, value) => setInputValue(value)} onKeyDown={(event) => { if (event.key === 'Enter' && confirmed && !isDeleting) { event.preventDefault();