|
|
@@ -1,5 +1,5 @@
|
|
|
import React, {
|
|
|
- useCallback, useState, FC, useEffect,
|
|
|
+ useCallback, useState, FC, useEffect, ReactNode,
|
|
|
} from 'react';
|
|
|
|
|
|
import nodePath from 'path';
|
|
|
@@ -93,6 +93,15 @@ const isDroppable = (fromPage?: Partial<IPageHasId>, newParentPage?: Partial<IPa
|
|
|
return pagePathUtils.canMoveByPath(fromPage.path, newPathAfterMoved) && !pagePathUtils.isUsersTopPage(newParentPage.path);
|
|
|
};
|
|
|
|
|
|
+// Component wrapper to make a child element not draggable
|
|
|
+// https://github.com/react-dnd/react-dnd/issues/335
|
|
|
+type NotDraggableProps = {
|
|
|
+ children: ReactNode,
|
|
|
+};
|
|
|
+const NotDraggableForClosableTextInput = (props: NotDraggableProps): JSX.Element => {
|
|
|
+ return <div draggable onDragStart={e => e.preventDefault()}>{props.children}</div>;
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
const { t } = useTranslation();
|
|
|
@@ -439,13 +448,17 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
</div>
|
|
|
{ isRenameInputShown
|
|
|
? (
|
|
|
- <ClosableTextInput
|
|
|
- value={nodePath.basename(page.path ?? '')}
|
|
|
- placeholder={t('Input page name')}
|
|
|
- onClickOutside={() => { setRenameInputShown(false) }}
|
|
|
- onPressEnter={onPressEnterForRenameHandler}
|
|
|
- inputValidator={inputValidator}
|
|
|
- />
|
|
|
+ <div className="flex-fill">
|
|
|
+ <NotDraggableForClosableTextInput>
|
|
|
+ <ClosableTextInput
|
|
|
+ value={nodePath.basename(page.path ?? '')}
|
|
|
+ placeholder={t('Input page name')}
|
|
|
+ onClickOutside={() => { setRenameInputShown(false) }}
|
|
|
+ onPressEnter={onPressEnterForRenameHandler}
|
|
|
+ inputValidator={inputValidator}
|
|
|
+ />
|
|
|
+ </NotDraggableForClosableTextInput>
|
|
|
+ </div>
|
|
|
)
|
|
|
: (
|
|
|
<>
|
|
|
@@ -499,12 +512,16 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
</li>
|
|
|
|
|
|
{isEnableActions && isNewPageInputShown && (
|
|
|
- <ClosableTextInput
|
|
|
- placeholder={t('Input page name')}
|
|
|
- onClickOutside={() => { setNewPageInputShown(false) }}
|
|
|
- onPressEnter={onPressEnterForCreateHandler}
|
|
|
- inputValidator={inputValidator}
|
|
|
- />
|
|
|
+ <div className="flex-fill">
|
|
|
+ <NotDraggableForClosableTextInput>
|
|
|
+ <ClosableTextInput
|
|
|
+ placeholder={t('Input page name')}
|
|
|
+ onClickOutside={() => { setNewPageInputShown(false) }}
|
|
|
+ onPressEnter={onPressEnterForCreateHandler}
|
|
|
+ inputValidator={inputValidator}
|
|
|
+ />
|
|
|
+ </NotDraggableForClosableTextInput>
|
|
|
+ </div>
|
|
|
)}
|
|
|
{
|
|
|
isOpen && hasChildren() && currentChildren.map((node, index) => (
|