improve: deeplinking behavior (#4960)

* add passing tests for fragment rewriting

* add failing fragment retention tests

* fire legacy `show` actions before standard ones

* skip failing tests

* remove extra line
This commit is contained in:
kyle
2018-10-19 17:33:30 -05:00
committed by GitHub
parent 505d056c71
commit 3df9fad68a
2 changed files with 31 additions and 7 deletions

View File

@@ -77,12 +77,11 @@ export const parseDeepLinkHash = (rawHash) => ({ layoutActions, layoutSelectors,
const isShownKey = layoutSelectors.isShownKeyFromUrlHashArray(hashArray)
const [type, tagId, maybeOperationId] = isShownKey
const [type, tagId = "", maybeOperationId = ""] = isShownKey
if(type === "operations") {
// we're going to show an operation, so we need to expand the tag as well
const tagIsShownKey = layoutSelectors.isShownKeyFromUrlHashArray([tagId])
layoutActions.show(tagIsShownKey)
// If an `_` is present, trigger the legacy escaping behavior to be safe
// TODO: remove this in v4.0, it is deprecated
@@ -90,9 +89,9 @@ export const parseDeepLinkHash = (rawHash) => ({ layoutActions, layoutSelectors,
console.warn("Warning: escaping deep link whitespace with `_` will be unsupported in v4.0, use `%20` instead.")
layoutActions.show(tagIsShownKey.map(val => val.replace(/_/g, " ")), true)
}
}
layoutActions.show(isShownKey, true)
layoutActions.show(tagIsShownKey, true)
}
// If an `_` is present, trigger the legacy escaping behavior to be safe
// TODO: remove this in v4.0, it is deprecated
@@ -101,6 +100,8 @@ export const parseDeepLinkHash = (rawHash) => ({ layoutActions, layoutSelectors,
layoutActions.show(isShownKey.map(val => val.replace(/_/g, " ")), true)
}
layoutActions.show(isShownKey, true)
// Scroll to the newly expanded entity
layoutActions.scrollTo(isShownKey)
}