Skip to content

Commit

Permalink
Fix: Path table is removed when we rearrange items (#3804)
Browse files Browse the repository at this point in the history
  • Loading branch information
naman-bruno authored Jan 16, 2025
1 parent 472b545 commit 5bfcc9b
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,16 @@ export const collectionsSlice = createSlice({
const { updateReorderedItem } = action.payload;
const params = item.draft.request.params;

item.draft.request.params = updateReorderedItem.map((uid) => {
return params.find((param) => param.uid === uid);
const queryParams = params.filter((param) => param.type === 'query');
const pathParams = params.filter((param) => param.type === 'path');

// Reorder only query params based on updateReorderedItem
const reorderedQueryParams = updateReorderedItem.map((uid) => {
return queryParams.find((param) => param.uid === uid);
});

// update request url
item.draft.request.params = [...reorderedQueryParams, ...pathParams];

// Update request URL
const parts = splitOnFirst(item.draft.request.url, '?');
const query = stringifyQueryParams(filter(item.draft.request.params, (p) => p.enabled && p.type === 'query'));
if (query && query.length) {
Expand Down

0 comments on commit 5bfcc9b

Please sign in to comment.