Commit a5ec97b
authored
fix(categories): filter null/empty segments before saving class name (#902)
* fix(categories): filter null/empty segments before saving class name
When editing a category with the Parent field set to "None" and the name
untouched, [].concat(this.editing.name) could produce [null] because
this.editing.name is initialized from cat.subname which may be null/undefined
for freshly-created or corrupted classes. Any such null value gets written
into settings.json under classes[].name and later serialized into the
categorize() query, where the query interpreter treats it as a variable
reference and raises
QueryInterpretException: Tried to reference variable 'null' which is not defined
breaking every chart that uses categorize().
Guard handleSubmit() so that:
- parent is coerced to [] if it is not an array
- null/undefined/empty-string segments are dropped from the final name
- if nothing remains (no parent, no name), save is aborted silently
Fixes ActivityWatch/activitywatch#1355
* fix(categories): require leaf name to be valid; do not collapse into parent
Address greptile review on #902: the previous version filtered null/undef/''
from the concatenated (parent + name) array as a whole. If the user cleared
the Name field on a child category, the leaf would be dropped and the
resulting name would equal the parent's name, effectively overwriting the
child into a duplicate of its parent.
Split the check:
- filter null/undef/'' out of the parent segments
- abort the save entirely if the leaf (editing.name) itself is invalid,
so an empty name never silently collapses a child into its parent.
---------
Co-authored-by: fanxing11 <fanxing11@users.noreply.github.com>1 parent 464405d commit a5ec97b
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
148 | 162 | | |
149 | 163 | | |
150 | | - | |
| 164 | + | |
151 | 165 | | |
152 | 166 | | |
153 | 167 | | |
| |||
0 commit comments