Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
yzh990918 committed May 8, 2023
1 parent 01c7e8d commit 1a48846
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/components/main/MessageItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { For, Show } from 'solid-js/web'
import { createSignal, onCleanup } from 'solid-js'
import { createSignal } from 'solid-js'
import { useStore } from '@nanostores/solid'
import { useClipboardCopy } from '@/hooks'
import { deleteMessageByConversationId, spliceMessageByConversationId, spliceUpdateMessageByConversationId } from '@/stores/messages'
Expand Down Expand Up @@ -103,7 +103,8 @@ export default (props: Props) => {
>
<div class="max-w-base flex gap-4 overflow-hidden">
<div class={`shrink-0 w-7 h-7 rounded-md op-80 ${roleClass[props.message.role]}`} />
<div class={`sm:hidden block absolute bottom-2 right-4 z-10 op-70 cursor-pointer ${isEditing() && '!hidden'}`}>
<div id="menuList-wrapper" class={`sm:hidden block absolute bottom-2 right-4 z-10 op-70 cursor-pointer ${isEditing() && '!hidden'}`}>
{/* TODO: hiden when clickOutside */}
<DropDownMenu menuList={menuList()}>
<div class="text-xl i-carbon:overflow-menu-horizontal" />
</DropDownMenu>
Expand Down
11 changes: 2 additions & 9 deletions src/components/ui/base/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as menu from '@zag-js/menu'
import { normalizeProps, useMachine } from '@zag-js/solid'
import { Show, children, createEffect, createMemo, createUniqueId } from 'solid-js'
import { Dynamic, For, Portal, spread } from 'solid-js/web'
import { useClickOutside } from '@/hooks'
import type { Accessor, JSX, JSXElement } from 'solid-js'
import type { JSX, JSXElement } from 'solid-js'

export interface MenuItem {
id: string
Expand All @@ -17,7 +16,7 @@ export interface MenuItem {
interface Props {
children: JSX.Element
menuList: MenuItem[]
close?: () => Accessor<boolean>
close?: boolean
}

export const DropDownMenu = (props: Props) => {
Expand All @@ -33,7 +32,6 @@ export const DropDownMenu = (props: Props) => {
},
}),
)
let dropDownMenuRef: HTMLDivElement

const api = createMemo(() => menu.connect(state, send, normalizeProps))

Expand All @@ -48,11 +46,6 @@ export const DropDownMenu = (props: Props) => {
createEffect(() => {
// https://github.com/chakra-ui/zag/issues/595
api().setPositioning({})

dropDownMenuRef = document.getElementById('DropDownMenuRef') as HTMLDivElement
useClickOutside(dropDownMenuRef, () => {
api().close()
})
})

return (
Expand Down

0 comments on commit 1a48846

Please sign in to comment.