-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(nested): Prevent infinite loops when resolving path #20390
Conversation
Note: I searched for |
caa1cd8
to
ab43fc4
Compare
I moved this to register instead which also detects duplicate siblings. Should we skip this check for leaf nodes? #12286 seems to work fine now if the only duplicates are leaves, getPath will be returning the wrong value for these still though and if only one of the duplicates is unmounted it will break the others because unregister cleans up all the references. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR by this far is good enough, duplicate leaf nodes should be warned as well because it confuses selected/activated values.
Generally speaking, duplicating item-value shouldn't be allowed/encouraged (it's almost impossible to properly handled from our end), if developers don't have confidence of avoiding item-value duplication in items, then using return-object
is a graceful way to cope with the issue.
I think we should also make this clear as a "Ceveat" in document in addition to the warning
@@ -209,6 +213,15 @@ export const useNested = (props: NestedProps) => { | |||
return arr | |||
}), | |||
register: (id, parentId, isGroup) => { | |||
if (nodeIds.has(id)) { | |||
const path = getPath(id).join(' -> ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getPath(id)
can be a Symbol
, which throws TypeError: Cannot convert a Symbol value to a string
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
While loops used by components with nesting need some safety check to prevent freezing end-users tab. Performance overhead of the checks is close to none, while it makes a big difference in the field.
Error does not necessarily need to be developers fault. Data from the API may contain duplicates or it may be a result of some drag & copy functionality built on top of Vuetify's components.
I was advised to log a warning, but I just don't think it is better than throwing error
path
/parents
collection – unnecessary performance overhead if we can have cheaper solutionsmitigates #20389
Markup: