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 (
<TextInput
path={path}
name={name}
value={value as string || ''}
label={label}

View File

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

View File

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