Skip to content

Commit

Permalink
modal focus issue that kills latest chrome, dont show campaign type f… (
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishills authored Mar 18, 2024
1 parent f870c8f commit c7f9702
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 24 deletions.
4 changes: 2 additions & 2 deletions apps/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": "https://github.com/parcelvoy/platform",
"dependencies": {
"@fontsource/inter": "^4.5.14",
"@headlessui/react": "1.7.13",
"@headlessui/react": "1.7.18",
"@heroicons/react": "^2.0.11",
"@monaco-editor/react": "^4.4.6",
"@popperjs/core": "^2.11.6",
Expand All @@ -25,7 +25,7 @@
"react": "^18.2.0",
"react-charts": "^3.0.0-beta.57",
"react-dom": "^18.2.0",
"react-hook-form": "^7.33.0",
"react-hook-form": "7.51.1",
"react-hot-toast": "^2.4.0",
"react-popper": "^2.3.0",
"react-router-dom": "^6.4.2",
Expand Down
25 changes: 14 additions & 11 deletions apps/ui/src/ui/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dialog, Transition } from '@headlessui/react'
import { Fragment, PropsWithChildren, ReactNode, useRef } from 'react'
import { Fragment, PropsWithChildren, ReactNode } from 'react'
import Button from './Button'
import { CloseIcon } from './icons'
import './Modal.css'
Expand Down Expand Up @@ -27,14 +27,14 @@ export default function Modal({
size,
zIndex = 999,
}: PropsWithChildren<ModalProps>) {
const ref = useRef<HTMLDivElement>(null)
return (
<Transition.Root show={open} as={Fragment}>
<Dialog as="div"
<Dialog
as="div"
className={`modal ${size ?? 'small'}`}
onClose={onClose}
style={{ zIndex }}
initialFocus={ref}>
>
<Transition.Child
as={Fragment}
enter="transition-enter"
Expand Down Expand Up @@ -85,7 +85,7 @@ export default function Modal({
</Dialog.Description>
)
}
<div className="modal-content" ref={ref}>
<div className="modal-content">
{children}
</div>
{
Expand All @@ -96,12 +96,15 @@ export default function Modal({
)
}
{
size !== 'fullscreen' && <Button
className="modal-close"
size="tiny"
variant="plain"
icon={<CloseIcon />}
onClick={() => onClose(false)} />
size !== 'fullscreen' && (
<Button
className="modal-close"
size="tiny"
variant="plain"
icon={<CloseIcon />}
onClick={() => onClose(false)}
/>
)
}
</Dialog.Panel>
</Transition.Child>
Expand Down
8 changes: 5 additions & 3 deletions apps/ui/src/views/campaign/CampaignForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const TypeSelection = ({ campaign, form }: { campaign?: Campaign, form: UseFormR
</>
}

export function CampaignForm({ campaign, onSave }: CampaignEditParams) {
export function CampaignForm({ campaign, onSave, type }: CampaignEditParams) {
const [project] = useContext(ProjectContext)

const [providers, setProviders] = useState<Provider[]>([])
Expand Down Expand Up @@ -275,7 +275,7 @@ export function CampaignForm({ campaign, onSave }: CampaignEditParams) {
return (
<FormWrapper<CampaignCreateParams>
onSubmit={async (item) => await handleSave(item)}
defaultValues={campaign ?? { type: 'blast' }}
defaultValues={campaign ?? { type: type ?? 'blast' }}
submitLabel="Save"
>
{form => (
Expand All @@ -289,7 +289,9 @@ export function CampaignForm({ campaign, onSave }: CampaignEditParams) {
form={form}
name="tags"
/>
<TypeSelection campaign={campaign} form={form} />
{
!type && <TypeSelection campaign={campaign} form={form} />
}
{
campaign
? (
Expand Down
42 changes: 34 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c7f9702

Please sign in to comment.