Fix: Kit name input & validation - Export flow [ED-19345]#31376
Fix: Kit name input & validation - Export flow [ED-19345]#31376ManorHazaz merged 14 commits intoelementor:mainfrom
Conversation
| .replace( /[<>:"/\\|?*]/g, '' ) | ||
| .trim(); | ||
|
|
||
| const fileName = sanitizedKitName || 'elementor-kit'; |
There was a problem hiding this comment.
Do you need the fallback twice?
There was a problem hiding this comment.
The second default would only be needed in the edge case where someone enters a kit name consisting only of special characters (like "///???") that get completely removed during sanitization.
But added a variable to hold them both
|
|
||
| const kitName = exportContext.data.kitInfo?.title || 'elementor-kit'; | ||
| const sanitizedKitName = kitName | ||
| .replace( /[<>:"/\\|?*]/g, '' ) |
There was a problem hiding this comment.
Maybe give the regex a readable variable name?
|
|
||
| const validateKitName = ( value ) => { | ||
| if ( ! value || 0 === value.trim().length ) { | ||
| return __( 'Must add a kit name', 'elementor' ); |
There was a problem hiding this comment.
| return __( 'Must add a kit name', 'elementor' ); | |
| return __( 'Kit name is required', 'elementor' ); |
There was a problem hiding this comment.
No based on Shiri design
| return { ...state, kitInfo: { ...state.kitInfo, title: payload } }; | ||
| case 'SET_KIT_DESCRIPTION': | ||
| return { ...state, kitInfo: { ...state.kitInfo, description: payload } }; | ||
| case 'SET_KIT_NAME_VALIDATOR': |
There was a problem hiding this comment.
Not sure I understand why the validator is part of the context? 🤔
There was a problem hiding this comment.
Removed, I was sure I needed it for some reason
| export default function KitName() { | ||
| const exportContext = useContext( ExportContext ); | ||
| const [ error, setError ] = useState( null ); | ||
| const [ touched, setTouched ] = useState( false ); |
There was a problem hiding this comment.
touched did not make sense immediately. Maybe inputModified or something.
There was a problem hiding this comment.
Removed completely, and simplified the code.
No description provided.