Fix issue with enter not properly submitting the edit info modal
This commit is contained in:
@ -47,6 +47,10 @@ type RecommendationCommentsProps = {
|
||||
recommendationsWithNotes: Recommendation[]
|
||||
}
|
||||
|
||||
export interface UpdateTitleEvent extends Event {
|
||||
title?: string
|
||||
}
|
||||
|
||||
const RecommendationComments = (
|
||||
props: RecommendationCommentsProps
|
||||
): JSX.Element => {
|
||||
@ -251,10 +255,6 @@ export function ArticleContainer(props: ArticleContainerProps): JSX.Element {
|
||||
setLabels(event.labels ?? [])
|
||||
}
|
||||
|
||||
interface UpdateTitleEvent extends Event {
|
||||
title?: string
|
||||
}
|
||||
|
||||
const handleUpdateTitle = (event: UpdateTitleEvent) => {
|
||||
if (event.title) {
|
||||
setTitle(event.title)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import {
|
||||
ModalButtonBar,
|
||||
ModalContent,
|
||||
ModalOverlay,
|
||||
ModalRoot,
|
||||
@ -215,7 +216,15 @@ function EditItemModal(props: EditItemModalProps): JSX.Element {
|
||||
}
|
||||
|
||||
return (
|
||||
<ModalRoot defaultOpen onOpenChange={props.onOpenChange} css={{}}>
|
||||
<ModalRoot
|
||||
defaultOpen
|
||||
modal={true}
|
||||
onOpenChange={() => {
|
||||
console.log('props.onOpenChange')
|
||||
props.onOpenChange(false)
|
||||
}}
|
||||
css={{}}
|
||||
>
|
||||
<ModalOverlay />
|
||||
<ModalContent
|
||||
css={{ bg: '$grayBg', p: '20px', maxWidth: '420px' }}
|
||||
@ -230,6 +239,7 @@ function EditItemModal(props: EditItemModalProps): JSX.Element {
|
||||
<form
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault()
|
||||
props.onSave(title, author, description, savedAt, publishedAt)
|
||||
}}
|
||||
>
|
||||
<HStack distribution="start" css={{ width: '100%' }}>
|
||||
@ -309,30 +319,10 @@ function EditItemModal(props: EditItemModalProps): JSX.Element {
|
||||
}}
|
||||
maxLength={4000}
|
||||
/>
|
||||
<HStack distribution="end" css={{ mt: '12px', width: '100%' }}>
|
||||
<Button
|
||||
onClick={() => props.onOpenChange(false)}
|
||||
style="cancelGeneric"
|
||||
css={{ mr: '5px' }}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
props.onSave(
|
||||
title,
|
||||
author,
|
||||
description,
|
||||
savedAt,
|
||||
publishedAt
|
||||
)
|
||||
}}
|
||||
style="ctaDarkYellow"
|
||||
css={{ mb: '0px' }}
|
||||
>
|
||||
Save Changes
|
||||
</Button>
|
||||
</HStack>
|
||||
<ModalButtonBar
|
||||
onOpenChange={props.onOpenChange}
|
||||
acceptButtonLabel="Save Changes"
|
||||
/>
|
||||
</form>
|
||||
</Box>
|
||||
</VStack>
|
||||
|
||||
@ -536,6 +536,10 @@ export default function Home(): JSX.Element {
|
||||
article.description = description
|
||||
article.savedAt = savedAt
|
||||
article.publishedAt = publishedAt
|
||||
|
||||
const titleEvent = new Event('updateTitle') as UpdateTitleEvent
|
||||
titleEvent.title = title
|
||||
document.dispatchEvent(titleEvent)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user