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): set slugified title as permalink #5264
Conversation
@mpaktiti I think setting the handle temporarily is to handle the case where you would navigate out of the PDP and then click back again and the product you were editing would disappear because products are only accessible by handle so this newly created product would never be accessible. Can you double check that you haven't introduced a new bug around that scenario? |
@zenweasel Steps followed:
Let me know if I didn't get the steps right. |
Are you able to click back into that product? If so I think we're OK |
@zenweasel Yes I can step back and edit it. The URL uses the product ID. For example, for an untitled product I created the URL is |
@mpaktiti You need to sign your commits when committing to the open source projects. Click on "details" next to the DCO check on how to rectify |
@manueldelreal can you give this a quick test please? |
Signed-off-by: Maria Paktiti <maria@reactioncommerce.com>
c0319fb
to
0419c60
Compare
@@ -816,7 +814,7 @@ Meteor.methods({ | |||
// Should be a call similar to the line below. | |||
[field]: createHandle(Reaction.getSlug(value), _id) // handle should be unique | |||
}; | |||
} else if (field === "title" && doc.handle === doc._id) { |
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 purpose of this is to ensure that permalink isn't updated every time someone changes a title. With the removal of the ID
being the default permalink, this is definitely less useful; however, there should be new check added for the existence of the permalink and block updates if it's set.
The permalink changing every time the title changes will cause broken links. If someone wants to break their permalink, they can do so from the field itself, and make whatever redirects they want in their storefront if necessary.
What I'd like to see from this is:
- The permalink should be set the first time automatically based on the title.
- The permalink doesn't update automatically with the title change if it's already set.
- The permalink is manually updateable through the field, which it is now.
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.
Hey @mikemurray , thanks for the feedback. One clarification about the first bullet point.
When we create a product the title is null. I'll have the permalink updated automatically only the first time the title is set by the user. Until then it will be null (and after the first update it will not be updated automatically again). Sounds good or should we populate it initially with a default value?
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 permalink could be blank until the first update of the title. Products can't be published with a null title. Not sure about a null permalink, but the null title will make sure the permalink it set.
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.
is this thread resolved? asking for a friend that needs to test this.
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.
@manueldelreal No it's not! I'll ping you once it's ready for testing.
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 changed this locally and this is the behavior I see:
- Go to Products and create a new product. The title is not set yet and therefore the permalink is empty as well.
- Set a value for title -> permalink is updated automatically
- Update the title -> permalink is not updated automatically
- Update the permalink manually -> update successful
However, if I delete the permalink manually and try to Publish, the system lets me do it. Should I add the same validation we have for Title and not allow them to publish if the permalink is null?
@mikemurray @zenweasel
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.
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 think it's fine to make the permalink required since it no-longer defaults to the product id.
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.
@mikemurray Can you please review the changes I just pushed? Behaviour is the same as I described in my previous comment, plus if you try to delete the permalink you get this error:
@zenweasel @mpaktiti waiting on the conversation thread between @mikemurray and @mpaktiti to be resolved before testing this one with its final form. cc @zenweasel |
Signed-off-by: Maria Paktiti <maria.paktiti@gmail.com>
Signed-off-by: Maria Paktiti <maria.paktiti@gmail.com>
Signed-off-by: Maria Paktiti <maria.paktiti@gmail.com>
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.
LGTM 👍
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.
Signed-off-by: Mike Murray <hellomikemurray@gmail.com>
Resolves #4735
Impact: major
Type: bugfix
Issue
When you create a product, the permalink (handle) is set to a random ID instead of the slugified version of the title. This is happening because:
doc.handle === doc._id
is never true (the handle is set to a random ID, not the doc ID)Steps to reproduce:
Solution
I removed the
doc.handle === doc._id
condition. This way when the user sets a Title for the product, the handle is updated. I also removed the initial population with a random ID because I see no use for it.Breaking changes
None
Testing