mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #24979 from overleaf/mj-editor-event-hook
[web] Introduce React hook wrapper around sendMB and friends GitOrigin-RevId: 3c693ae609c6d4e5ba280c45096692aca47975ca
This commit is contained in:
committed by
Copybot
parent
0b9cb185fa
commit
e98addf33a
@@ -1,7 +1,8 @@
|
||||
import DropdownListItem from '@/features/ui/components/bootstrap-5/dropdown-list-item'
|
||||
import { DropdownItem } from '@/features/ui/components/bootstrap-5/dropdown-menu'
|
||||
import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
|
||||
import { useNestableDropdown } from '@/shared/hooks/use-nestable-dropdown'
|
||||
import { MouseEventHandler, ReactNode } from 'react'
|
||||
import { MouseEventHandler, ReactNode, useCallback } from 'react'
|
||||
|
||||
type MenuBarOptionProps = {
|
||||
title: string
|
||||
@@ -11,18 +12,30 @@ type MenuBarOptionProps = {
|
||||
href?: string
|
||||
target?: string
|
||||
rel?: string
|
||||
eventKey?: string
|
||||
}
|
||||
|
||||
export const MenuBarOption = ({
|
||||
title,
|
||||
onClick,
|
||||
onClick: clickHandler,
|
||||
href,
|
||||
disabled,
|
||||
trailingIcon,
|
||||
target,
|
||||
rel,
|
||||
eventKey,
|
||||
}: MenuBarOptionProps) => {
|
||||
const { setSelected } = useNestableDropdown()
|
||||
const { sendEvent } = useEditorAnalytics()
|
||||
const onClick: MouseEventHandler = useCallback(
|
||||
e => {
|
||||
if (eventKey) {
|
||||
sendEvent('menu-bar-option-click', { key: eventKey })
|
||||
}
|
||||
return clickHandler?.(e)
|
||||
},
|
||||
[clickHandler, eventKey, sendEvent]
|
||||
)
|
||||
return (
|
||||
<DropdownListItem>
|
||||
<DropdownItem
|
||||
|
||||
Reference in New Issue
Block a user