Merge pull request #2345 from omnivore-app/fix/confirm-info-submit

Fix issue with enter not properly submitting the edit info modal
This commit is contained in:
Jackson Harper 2023-06-13 16:26:24 +08:00 committed by GitHub
commit 9ad516520f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 31 deletions

View file

@ -23,7 +23,8 @@ export function LibraryListCard(props: LinkedItemCardProps): JSX.Element {
return (
<VStack
css={{
p: '20px',
px: '15px',
py: '10px',
height: '100%',
cursor: 'pointer',
gap: '10px',

View file

@ -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)

View file

@ -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>

View file

@ -7,7 +7,10 @@ import {
} from '../../../lib/networking/queries/useGetArticleQuery'
import { useRouter } from 'next/router'
import { VStack } from './../../../components/elements/LayoutPrimitives'
import { ArticleContainer } from './../../../components/templates/article/ArticleContainer'
import {
ArticleContainer,
UpdateTitleEvent,
} from './../../../components/templates/article/ArticleContainer'
import { PdfArticleContainerProps } from './../../../components/templates/article/PdfArticleContainer'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useKeyboardShortcuts } from '../../../lib/keyboardShortcuts/useKeyboardShortcuts'
@ -536,6 +539,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)
}}
/>
)}