Просмотр исходного кода

refactor: enhance input validation in EditablePagePath for improved user experience

Shun Miyazawa 8 месяцев назад
Родитель
Сommit
864b10e3bc

+ 3 - 1
apps/app/src/features/openai/client/components/AiAssistant/AiAssistantManagementModal/SelectablePagePageList.tsx

@@ -2,6 +2,7 @@ import React, {
   useMemo, memo, useState, useCallback, useRef, useEffect,
 } from 'react';
 
+import { pagePathUtils } from '@growi/core/dist/utils';
 import { useRect } from '@growi/ui/dist/utils';
 import { useTranslation } from 'react-i18next';
 import AutosizeInput from 'react-input-autosize';
@@ -119,7 +120,8 @@ const EditablePagePath = memo((props: EditablePagePathProps): JSX.Element => {
   const handleInputKeyDown = useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
     if (e.key === 'Enter') {
 
-      if (disablePagePaths.includes(inputValue)) {
+      if (inputValue === '' || disablePagePaths.includes(inputValue) || !pagePathUtils.isCreatablePage(inputValue)) {
+        handleInputBlur();
         return;
       }