@@ -29,7 +30,14 @@ const NavigationItemEditor: React.FC = ({baseUrl, ite
value={item.label}
hideTitle
onChange={e => updateItem?.({label: e.target.value})}
- onKeyDown={() => clearError?.('label')}
+ onKeyDown={(e) => {
+ updateItem?.({label: (e.target as HTMLInputElement).value});
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ addItem?.();
+ }
+ !!item.errors.label && clearError?.('label');
+ }}
/>
@@ -44,7 +52,19 @@ const NavigationItemEditor: React.FC = ({baseUrl, ite
value={item.url}
hideTitle
onChange={value => updateItem?.({url: value || ''})}
- onKeyDown={() => clearError?.('url')}
+ onKeyDown={(e) => {
+ const urls = formatUrl((e.target as HTMLInputElement).value, baseUrl, true);
+ updateItem?.({url: urls.save || ''});
+ }}
+ onKeyUp={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ const urls = formatUrl((e.target as HTMLInputElement).value, baseUrl, true);
+ updateItem?.({url: urls.save || ''});
+ addItem?.();
+ }
+ !!item.errors.url && clearError?.('url');
+ }}
/>
{action}