Skip to content

Commit 430e2a9

Browse files
committed
Fixes #3596
Wrap `isShownKey` values in a function that replaces spaces with underscores. When parsing the hash on route change, replace the spaces in the values with underscores again.
1 parent 7cd4299 commit 430e2a9

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/core/components/operations.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import PropTypes from "prop-types"
33
import { helpers } from "swagger-client"
4-
4+
import { replaceSpacesWithUnderscores } from "core/utils"
55
const { opId } = helpers
66

77
export default class Operations extends React.Component {
@@ -69,7 +69,7 @@ export default class Operations extends React.Component {
6969
let tagExternalDocsDescription = tagObj.getIn(["tagDetails", "externalDocs", "description"])
7070
let tagExternalDocsUrl = tagObj.getIn(["tagDetails", "externalDocs", "url"])
7171

72-
let isShownKey = ["operations-tag", tag]
72+
let isShownKey = ["operations-tag", replaceSpacesWithUnderscores(tag)]
7373
let showTag = layoutSelectors.isShown(isShownKey, docExpansion === "full" || docExpansion === "list")
7474

7575
return (
@@ -124,7 +124,7 @@ export default class Operations extends React.Component {
124124

125125
const operationId =
126126
op.getIn(["operation", "operationId"]) || op.getIn(["operation", "__originalOperationId"]) || opId(op.get("operation"), path, method) || op.get("id")
127-
const isShownKey = ["operations", tag, operationId]
127+
const isShownKey = ["operations", replaceSpacesWithUnderscores(tag), replaceSpacesWithUnderscores(operationId)]
128128

129129
const allowTryItOut = specSelectors.allowTryItOutFor(op.get("path"), op.get("method"))
130130
const response = specSelectors.responseFor(op.get("path"), op.get("method"))

src/core/plugins/deep-linking/spec-wrap-actions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import scrollTo from "scroll-to-element"
2+
import { replaceSpacesWithUnderscores } from "core/utils"
23

34
const SCROLL_OFFSET = -5
45
let hasHashBeenParsed = false
@@ -27,7 +28,7 @@ export const updateResolved = (ori, { layoutActions, getConfigs }) => (...args)
2728
hash = hash.slice(1)
2829
}
2930

30-
let [tag, operationId] = hash.split("/")
31+
let [tag, operationId] = hash.split("/").map(v => replaceSpacesWithUnderscores(v))
3132

3233
if(tag && operationId) {
3334
// Pre-expand and scroll to the operation

src/core/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,5 @@ export const shallowEqualKeys = (a,b, keys) => {
650650
return eq(a[key], b[key])
651651
})
652652
}
653+
654+
export const replaceSpacesWithUnderscores = (str) => str.replace(/\s/, "_")

0 commit comments

Comments
 (0)