Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
if the keypad submodule is enabled, when you get to the payment page. if you use the keypad to enter a price with a decimal, the amount disappears temporarily when entering the amount
javascript error is posted in image:
Comment | File | Size | Author |
---|---|---|---|
#31 | commerce_pos-payment_amount_disapears-2933461-30.patch | 196.38 KB | gmem |
| |||
#18 | 2933461-18.patch | 1.98 KB | subhojit777 |
| |||
#13 | payment-amount-disappear-2933461-13.patch | 1.92 KB | deepakaryan1988 |
| |||
#11 | payment-amount-disappear-2933461-11.patch | 975 bytes | deepakaryan1988 |
#5 | 2933461-5.patch | 485 bytes | mglaman |
Comments
Comment #2
thejacer87 CreditAttribution: thejacer87 at Acro Commerce commentedComment #3
sorabh.v6I also faced the same bug. I believe it is because we are using input type number. When I changed the input type to text then I did not saw that bug again. Please refer the attached gif -
Comment #4
mglamanWouldn't the proper fix to use `parseInt` in the JavaScript?
Comment #5
mglamanGive it a try
Comment #7
mglamanOkay, that doesn't work because it doesn't append. So the input needs to be changed to text, as specified in #3
Comment #8
sorabh.v6@mglaman Changing this field to text will remove the validation of type number. Previously this field was a textfield and to apply validation I had to change that to number field. If we make it a textfield then we will have to apply custom validation.
Comment #9
sorabh.v6@mglaman This is the issue where the field was changed from `text` to `number` - https://www.drupal.org/project/commerce_pos/issues/2916647
Comment #10
deepakaryan1988Comment #11
deepakaryan1988Hello,
I have made the patch for attaching .0 at the end. Now, I am uploading it but there is still lots of things to do.
I'll update the patch as I further progress.
Comment #13
deepakaryan1988Thanks to @travis.
Submitting a patch now.
For later on, I'll disable " . " once it used once.
Comment #14
travis-bradbury CreditAttribution: travis-bradbury at Acro Commerce commentedThis needs a test that fails without the fix.
Comment #15
TimRutherford CreditAttribution: TimRutherford at Acro Commerce commentedComment #16
TimRutherford CreditAttribution: TimRutherford at Acro Commerce commentedAfter investigation, it does not seem possible to fix this in a clean way. The current solution in patch 13 has its issues and looks a bit confusing having a random 0 show up then get removed on next key press. I'd propose a couple solutions:
Personally I think #1 is the way to go. Its easy and pretty clean. We would need to make sure we fix the issues in https://www.drupal.org/project/commerce_pos/issues/2916647 though.
Comment #17
subhojit777Comment #18
subhojit777Agree with Tim et al that the
textfield
approach looks much cleaner.Comment #19
subhojit777There is a problem with #18. Entering
1.22000000
also throws error.Comment #20
subhojit777Not neat :( but fixes the problem. If we want to make it absolutely neat, then I would recommend providing a message to the end-user that the amount will rounded up to two digits, and use
round()
.Comment #21
subhojit777Lets decide whether to follow the JS/PHP approach to fix this problem, and then we can write tests.
Comment #22
jnrfred CreditAttribution: jnrfred commentedPatch in #20 looks good. The amount does not disappear temporarily when you use the keypad.
Comment #23
travis-bradbury CreditAttribution: travis-bradbury at Acro Commerce commented$form_state->setError($form['keypad']['amount'], $this->t('The amount should be of two digit precision.'));
Instead of "two" this should say the number from
$fraction_digit
.Comment #24
jnrfred CreditAttribution: jnrfred commentedThis patch addresses #23 fixes.
Comment #25
gmem CreditAttribution: gmem as a volunteer commentedSeeing as this is still an issue, I went ahead and rerolled the patch, as well as tweaked the styling on the input to limit the width - otherwise it overlaps the add cash amount button.
Comment #26
gmem CreditAttribution: gmem as a volunteer commentedComment #27
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedThe max width setting is overridden to 100% for me in both Chrome and FF, also I think it is better to set this via the field size from the form, not the CSS.
Comment #28
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedminor reroll and npm update
Comment #29
gmem CreditAttribution: gmem as a volunteer commentedRemoved the styling and set the size attribute to 10 with the same effect.
Comment #31
gmem CreditAttribution: gmem as a volunteer and at Acro Commerce commentedReroll
Comment #32
gmem CreditAttribution: gmem as a volunteer and at Acro Commerce commentedComment #34
smccabe CreditAttribution: smccabe as a volunteer and at Acro Commerce commentedComment #35
sorabh.v6