Skip to content

Commit

Permalink
worked on link dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveDuo committed Nov 6, 2023
1 parent 3fc1e3a commit 7cb34c6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/client/vanilla/link.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'

import * as DialogPrimitive from '@radix-ui/react-dialog'
import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon'
Expand All @@ -13,13 +13,18 @@ interface DialogProps {
}

const Dialog: React.FC<DialogProps> = ({ open, setOpen, selectedElement }) => {
const [link, setLink] = useState(selectedElement?.href ?? '')
const [link, setLink] = useState('')
const [newTab, setNewTab] = useState(true)

useEffect(() => {
setLink(selectedElement?.href ?? '')
}, [open])

const onSave = () => {
setOpen(false)

// TODO update dom element
selectedElement.href = link
selectedElement.target = newTab ? '_blank' : '_self'
}

return (
Expand Down

0 comments on commit 7cb34c6

Please sign in to comment.