-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix opening tag with colon shows not found page while opening for the first time #42381
Fix opening tag with colon shows not found page while opening for the first time #42381
Conversation
@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
* Escape colon from tag name | ||
*/ | ||
function escapeTagName(tag: string) { | ||
return tag?.replaceAll(CONST.COLON, '\\:'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bernhardoj I see there are many cases the BE replace :
by \:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what you are trying to request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You assume that the BE will replace :
with \\:
and I see there are some exceptional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bernhardoj If you enter the tag name is a:b the BE will return a\:b
and the optimistic data in your change will return a\\:b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see any pattern in how the BE replaces the colon?
cc @amyevans
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/libs/actions/Policy.ts
Outdated
@@ -3649,7 +3650,9 @@ function clearPolicyTagErrors(policyID: string, tagName: string) { | |||
|
|||
function renamePolicyTag(policyID: string, policyTag: {oldName: string; newName: string}) { | |||
const tagListName = Object.keys(allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {})[0]; | |||
const oldTag = allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`]?.[tagListName]?.tags?.[policyTag.oldName] ?? {}; | |||
const oldTagName = PolicyUtils.escapeTagName(policyTag.oldName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bernhardoj Why do we need to escape the old tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we escaped the tag name when creating, It means that the old tag is escaped. Unless you want to cover tags created before this PR was merged, in this case, I think it isn't a good way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tag name that we pass to the old name is the "cleaned" tag name.
const currentTagName = PolicyUtils.getCleanedTagName(route.params.tagName); |
Policy.renamePolicyTag(route.params.policyID, {oldName: currentTagName, newName: values.tagName.trim()}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bernhardoj Should we pass route.params.tagName instead of currentTagName
Policy.renamePolicyTag(route.params.policyID, {oldName: currentTagName, newName: values.tagName.trim()}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep it as it is. Having 2 different sources of the tag name, route.params.tagName
and currentTagName
makes it more confusing, IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we shouldn't make a redundant logic. Currently, we clean tag name and escape again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, we only need to escape new tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have updated it.
src/libs/actions/Policy.ts
Outdated
oldName: policyTag.oldName, | ||
newName: policyTag.newName, | ||
oldName: oldTagName, | ||
newName: newTagName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit hesitant when changing the param but everything seems to still work well
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-05-23.at.17.32.21.movAndroid: mWeb ChromeScreen.Recording.2024-05-23.at.17.30.30.moviOS: NativeScreen.Recording.2024-05-23.at.17.29.58.moviOS: mWeb SafariScreen.Recording.2024-05-23.at.17.28.02.movMacOS: Chrome / SafariScreen.Recording.2024-05-23.at.17.25.20.movMacOS: DesktopScreen.Recording.2024-05-23.at.17.26.33.mov |
BUG: Can't open tag with tag name including special characters (This is not related to our change, also happen on the main branch) Screen.Recording.2024-05-23.at.17.36.24.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, not merging since we are still on merge freezes and only merging/deploying emergency fixes/PRs.
We should be able to merge this PR now, but we have some conflicts. @bernhardoj Can you please resolve the conflicts, thanks. |
Done |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/techievivek in version: 1.4.77-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.77-11 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.77-11 🚀
|
Details
When we create a tag with a colon, the BE response will escape the colon and will make the optimistic tag name mismatch with the tag name from the BE. This PR optimistically escape the colon.
Fixed Issues
$ #41083
PROPOSAL: #41083 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screen.Recording.2024-05-20.at.17.52.00.mov
Android: mWeb Chrome
Screen.Recording.2024-05-20.at.17.46.08.mov
iOS: Native
Screen.Recording.2024-05-20.at.17.45.24.mov
iOS: mWeb Safari
Screen.Recording.2024-05-20.at.17.43.00.mov
MacOS: Chrome / Safari
Screen.Recording.2024-05-20.at.17.37.17.mov
MacOS: Desktop
Screen.Recording.2024-05-20.at.17.40.48.mov