Skip to content
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

Pod count should be trimmed #434

Closed
cheld opened this issue Feb 25, 2016 · 8 comments
Closed

Pod count should be trimmed #434

cheld opened this issue Feb 25, 2016 · 8 comments
Assignees

Comments

@cheld
Copy link
Contributor

cheld commented Feb 25, 2016

Issue details

leading or trailing spaces should be ignored. Similar behavior at Gmail

Steps to reproduce
  1. Open deploy from settings
  2. Enter "5 " as number of pods
Observed result

validation error

Expected result

ok

Comments

visually the input seems correct. So, the validation message is not understandable

@cheld
Copy link
Contributor Author

cheld commented Feb 25, 2016

Same for many other fields

@bryk
Copy link
Contributor

bryk commented Mar 1, 2016

I cannot reproduce on Chrome. What's your browser?

@cheld
Copy link
Contributor Author

cheld commented Mar 4, 2016

Sorry. I could not reproduce on Chrome either. I tested with Firefox 44 on Ubuntu

@bryk
Copy link
Contributor

bryk commented Mar 4, 2016

Closing.

@bryk bryk closed this as completed Mar 4, 2016
@cheld
Copy link
Contributor Author

cheld commented Mar 4, 2016

Sorry for confusion.

  • The bug is not reproducible on Chrome
  • The bug IS reproducible on Firefox.

Low prio, though.

Please reopen.

@bryk bryk reopened this Mar 4, 2016
@bryk bryk added this to the Post v1.0 milestone Mar 4, 2016
@floreks floreks added kind/bug Categorizes issue or PR as related to a bug. priority/P2 labels Mar 8, 2016
@maciaszczykm maciaszczykm self-assigned this Mar 9, 2016
@maciaszczykm
Copy link
Member

I've done pretty much investigation in this matter and it won't be easy to fix. To be honest I think we shouldn't fix it at all, because it's Firefox bug, not ours.

Firefox doesn't fully implement <input type="number"> behaviour. It performs number validation on input field, but it doesn't filter alpha and whitespace characters. Moreover, it seems to be not only one missing thing.

I've tried to create new directive kd-numbers-only and use it everywhere to ensure, that fields will work in the same way on every browser:

export default function numbersOnlyDirective() {
  return {
    require: 'ngModel',
    link: function (scope, element, attr, ngModelCtrl) {
      function filterInputValue(inputValue) {
        if (inputValue) {
          var transformedValue = inputValue.replace(/[^0-9]/g, '');
          if (transformedValue !== inputValue) {
            ngModelCtrl.$setViewValue(transformedValue);
            ngModelCtrl.$render();
          }
          return transformedValue;
        }
        return undefined;
      }
      ngModelCtrl.$parsers.unshift(filterInputValue);
    }
  };
}

Unfortunately providing whitespaces don't execute it on Firefox, only alpha characters. Moreover to make it work there was a need to switch <input type="number"> to <input type="text">.

There are too much issues with it on Firefox, that I believe we shouldn't create big workarounds just to make it work. I'd create a bug for it and perhaps change message to warn user about possible issues (there is even specific attribute for Firefox to display custom message only for it).

CC @floreks @bryk @cheld

@floreks floreks added kind/enhancement and removed kind/bug Categorizes issue or PR as related to a bug. priority/P2 labels Mar 10, 2016
@floreks
Copy link
Member

floreks commented Mar 10, 2016

If this is an issue with firefox type="number" implementation then this should be reported in there as a bug. Forcing this directive workaround will make code less readable and soon we may end up with many workarounds for specific browsers that will complicate the code and lower its quality.

I'd only add <ng-messages> in order to display some message when required or number validation fails. That's simple and doesn't require any workarounds.

@maciaszczykm
Copy link
Member

Adding <ng-messages> would require disabling default HTML5 validation with novalidate, and disabling OK button if validation result is false.

Other possible solution is adding x-moz-errormessage="Must be positive number". It would create custom message for Firefox browser.

Which one seems to be more suitable for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants