fix: example-request tab collision (#7989)

* fix: prevent response-example tabs from hijacking request sidebar selection

* fix: add selectors for examples with index

* test: better locator

* fix: duplicate name collision

* fix: refactor sidebar example handling functions for better clarity and reusability

* chore: cr comments
This commit is contained in:
Sid
2026-05-13 21:47:39 +05:30
committed by lohit
parent c12fe6cc12
commit 54567bbd69
12 changed files with 682 additions and 23 deletions

View File

@@ -28,11 +28,13 @@ const buildWorkspaceCollectionLookupKey = (workspacePathname, collectionPathname
const tabSchema = yup.object({
type: yup.string().required(),
accessor: yup.string().oneOf(['pathname', 'pathname::exampleName', 'type']).required(),
accessor: yup.string().oneOf(['pathname', 'pathname::exampleName', 'pathname::exampleIndex', 'type']).required(),
pathname: yup.string().nullable(),
permanent: yup.boolean().required(),
name: yup.string().optional(),
exampleName: yup.string().optional(),
exampleIndex: yup.number().integer().min(0).optional(),
exampleUid: yup.string().optional(),
request: yup.object({
tab: yup.string(),
width: yup.number().nullable(),
@@ -46,7 +48,7 @@ const tabSchema = yup.object({
});
const activeTabSchema = yup.object({
accessor: yup.string().oneOf(['pathname', 'pathname::exampleName', 'type']).required(),
accessor: yup.string().oneOf(['pathname', 'pathname::exampleName', 'pathname::exampleIndex', 'type']).required(),
value: yup.string().required()
});
@@ -500,7 +502,7 @@ class SnapshotManager {
return null;
}
if (!['pathname', 'pathname::exampleName', 'type'].includes(activeTab.accessor) || typeof activeTab.value !== 'string') {
if (!['pathname', 'pathname::exampleName', 'pathname::exampleIndex', 'type'].includes(activeTab.accessor) || typeof activeTab.value !== 'string') {
return null;
}