Skip to content

Commit

Permalink
Fix ViewManagerModel unique name validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ghsolomon authored and amcclain committed Jan 16, 2025
1 parent b2a95a1 commit 2d7e67a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## v72.0.0-SNAPSHOT - unreleased

### 🐞 Bug Fixes

* Fixed `ViewManagerModel` unique name validation.

### ⚙️ Technical

* Added support for providing custom `PersistenceProvider` implementations to `PersistOptions`.
Expand Down
3 changes: 2 additions & 1 deletion cmp/viewmanager/ViewManagerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
if (name.length > maxLength) {
return `Name cannot be longer than ${maxLength} characters`;
}
if (this.ownedViews.some(view => view.name === name && view.token != existing?.token)) {
const views = existing?.isGlobal ? this.globalViews : this.ownedViews;
if (views.some(view => view.name === name && view.token != existing?.token)) {
return `A ${this.typeDisplayName} with name '${name}' already exists.`;
}
return null;
Expand Down

0 comments on commit 2d7e67a

Please sign in to comment.