fix: ensures getDataByPath works

This commit is contained in:
James
2021-12-22 14:18:50 -05:00
parent 35bf092813
commit 140a3aa9ea
3 changed files with 4 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ const Text: React.FC<TextFieldType> = (props) => {
return ( return (
<TextInput <TextInput
path={path}
name={name} name={name}
value={value as string || ''} value={value as string || ''}
label={label} label={label}

View File

@@ -4,7 +4,8 @@
"node_modules", "node_modules",
"node_modules/**/node_modules", "node_modules/**/node_modules",
"src/admin", "src/admin",
"src/**/*.spec.ts" "src/**/*.spec.ts",
"demo/**/*.tsx"
], ],
"watch": [ "watch": [
"src/**/*.ts", "src/**/*.ts",

View File

@@ -7,7 +7,7 @@ const getDataByPath = (fields: Fields, path: string): unknown => {
const name = path.split('.').pop(); const name = path.split('.').pop();
const data = Object.keys(fields).reduce((matchedData, key) => { const data = Object.keys(fields).reduce((matchedData, key) => {
if (key.indexOf(`${path}.`) === 0) { if (key.indexOf(`${path}.`) === 0 || key === path) {
return { return {
...matchedData, ...matchedData,
[key.replace(pathPrefixToRemove, '')]: fields[key], [key.replace(pathPrefixToRemove, '')]: fields[key],