Skip to content

Commit fbab0f7

Browse files
committed
feat: handle onClick input
1 parent 7c19024 commit fbab0f7

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

packages/nextra-editor/src/components/sidebar/sidebar-controller/control-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ function ControlInput({ type }: Props): ReactElement {
2323

2424
const onClick = (e: React.MouseEvent<HTMLDivElement>) => {
2525
e.preventDefault()
26-
onComplete()
26+
if ((e.target as any).tagName !== 'INPUT') {
27+
onComplete()
28+
}
2729

2830
if (title) {
2931
dispatchEvent()
@@ -78,6 +80,7 @@ function ControlInput({ type }: Props): ReactElement {
7880
</span>
7981
<input
8082
className={cn(
83+
'nextra-add-contents-input',
8184
'focus-visible:box-shadow-none nx-ml-1 nx-w-full nx-px-1 nx-py-0.5',
8285
'nx-bg-gray-100 nx-text-gray-600 ',
8386
'dark:nx-bg-primary-100/5 dark:nx-text-gray-400',

packages/nextra-editor/src/components/sidebar/sortable-tree/sortable-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const SortableItem = forwardRef<HTMLDivElement, SortableItemProps>((props
7171
isSeparator && 'nx-cursor-default',
7272
isSeparator ? classes.separator : classes.link,
7373
active ? classes.active : classes.inactive,
74-
!isDragging && !active && classes.inactiveBgColor,
74+
!isControlAction && !isDragging && !active && classes.inactiveBgColor,
7575
isGhost && classes.ghost,
7676
clone && classes.clone,
7777
isControlAction && '!nx-pr-0',

packages/nextra-editor/src/components/sidebar/style.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ export const classes = {
1010
'contrast-more:nx-border-primary-500 contrast-more:dark:nx-border-primary-500',
1111
),
1212
inactive: cn(
13-
'nx-text-gray-500',
14-
'dark:nx-text-neutral-400 dark:hover:nx-bg-primary-100/5 dark:hover:nx-text-gray-50',
13+
'nx-text-gray-500 dark:nx-text-neutral-400',
1514
'contrast-more:nx-text-gray-900 contrast-more:dark:nx-text-gray-50',
1615
'contrast-more:nx-border-transparent contrast-more:hover:nx-border-gray-900 contrast-more:dark:hover:nx-border-gray-50',
1716
),

packages/nextra-editor/src/hooks/use-outside-click.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useEffect, useRef } from 'react'
22

3-
export default function useOutsideClick<T extends Element>(callback: () => any) {
3+
export default function useOutsideClick<T extends Element>(callback: (event?: MouseEvent) => any) {
44
const ref = useRef<T>(null)
55

66
useEffect(() => {
77
const handleClick = (event: MouseEvent) => {
88
if (ref.current && !ref.current.contains(event.target as any)) {
9-
callback()
9+
callback(event)
1010
}
1111
}
1212

0 commit comments

Comments
 (0)