Use maxlength instead of max for extra option length on upsell page - #577
Open
adrian-ionescu-dev wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cart/upsell.template.htmluses themaxattribute to apply an extra option's configured character limit:maxonly applies to numeric and date input types. It has no effect on<input type="text">, and it is not a valid<textarea>attribute at all. The character limit configured against a product's extra option is therefore not enforced anywhere on the upsell page, in either branch of the[%if [@length@] > '100'%]condition.The same
[@length@]value is applied correctly asmaxlengthelsewhere in the theme:products/includes/buying_options.template.htmlmaxlength="[@length@]"✅products/includes/components.template.htmlmaxlength="[@length@]"✅cart/upsell.template.htmlmax="[@length@]"❌So the product page enforces the limit and the upsell page silently does not. A customer editing a gift message, engraving, or other extra option from the upsell step can exceed the configured length.
Fix
Changed
maxtomaxlengthon both inputs:This brings the upsell page in line with how the same value is already handled on the product page.
How to reproduce on a dev site
Configure a product with a text extra option and set a character limit (e.g. 20).
Enable
checkout_upsell_extrain the checkout settings so the upsell page renders the extra-options editor.Add the product to cart and navigate to the upsell step.
Inspect the extra option field.
Before: renders
max="120"— the browser applies no limit, and you can type well past 20 characters.After: renders
maxlength="120"— input stops at 20 characters, matching the product page.