Title: ngChange handler called, on submit, for blank type="number" fields, when they haven't changed · Issue #17181 · angular/angular.js · GitHub
Open Graph Title: ngChange handler called, on submit, for blank type="number" fields, when they haven't changed · Issue #17181 · angular/angular.js
X Title: ngChange handler called, on submit, for blank type="number" fields, when they haven't changed · Issue #17181 · angular/angular.js
Description: I suppose this doesn't meet the LTS definition of a critical bug. But I am going to file it here in case it is - at the very least - helpful to other people. I spent a lot of time tracking down this issue. It's confusing and non-obvious ...
Open Graph Description: I suppose this doesn't meet the LTS definition of a critical bug. But I am going to file it here in case it is - at the very least - helpful to other people. I spent a lot of time tracking down thi...
X Description: I suppose this doesn't meet the LTS definition of a critical bug. But I am going to file it here in case it is - at the very least - helpful to other people. I spent a lot of time tracking down...
Opengraph URL: https://github.com/angular/angular.js/issues/17181
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ngChange handler called, on submit, for blank type=\"number\" fields, when they haven't changed","articleBody":"I suppose this doesn't meet the LTS definition of a critical bug.\r\nBut I am going to file it here in case it is - at the very least - helpful to other people.\r\n\r\nI spent a lot of time tracking down this issue. It's confusing and non-obvious why this would happen.\r\n\r\n\r\n**I'm submitting a ...**\r\n\u003c!-- (check one with \"x\") --\u003e\r\n- [ ] regression from 1.7.0\r\n- [ ] security issue\r\n- [ ] issue caused by a new browser version\r\n- [x] other \u003c!--(Please do not submit support requests here - see above)--\u003e\r\n\r\n\r\n**Current behavior:**\r\n\r\nIf you initialise, or clear a `\u003cinput type=\"number\"\u003e` field to blank (ie `\"\"`). It's `ng-change` handler will always be called on submit. Even if it has not been changed.\r\n\r\n\r\n**Expected / new behavior:**\r\nChange handler does not get called.\r\n\r\n**Minimal reproduction of the problem with instructions:**\r\nAn example\r\n```\r\n\u003cscript src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js\"\u003e\u003c/script\u003e\r\n\r\n\u003cdiv ng-app=\"app\"\u003e\r\n \u003cdiv ng-controller=\"MainCtrl\"\u003e\r\n \u003cform ng-submit=\"submit()\"\u003e\r\n \u003cinput type=\"number\" ng-model=\"form.testNumber\" ng-change=\"changed()\"/\u003e\r\n \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\r\n \u003c/form\u003e\r\n \u003c/div\u003e\r\n\u003c/div\u003e\r\n````\r\n```\r\nvar app = angular.module(\"app\", []);\r\n\r\napp.controller(\"MainCtrl\", function ($scope) {\r\n $scope.form = {\r\n testNumber: \"\"\r\n };\r\n\r\n $scope.changed = function () {\r\n console.log(\"changed\");\r\n };\r\n\r\n $scope.submit = function () {\r\n console.log(\"submitted\");\r\n };\r\n});\r\n```\r\nsee: http://jsfiddle.net/6qxrygzm/1/\r\n\r\nClick the submit button in the demo. The console will log the message \"changed\" even though the field is untouched from its initialised value.\r\n\r\n**AngularJS version:** 1.8.2\r\n\r\n**Browser:** all | Chrome 98.0.4758.102 | Firefox 97.0.1 (64-bit)\r\n\r\n**Anything else:**\r\n\u003c!-- e.g. stacktraces, related issues, suggestions how to fix --\u003e\r\n","author":{"url":"https://github.com/BigBadaboom","@type":"Person","name":"BigBadaboom"},"datePublished":"2022-02-25T10:56:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/17181/angular.js/issues/17181"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d35214ba-2c4d-ec3d-7ffa-0388ff69b4de |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3B4:226F59:CF927:117D50:696E07EE |
| html-safe-nonce | b13767bf9ca98fe35e6dbe05e888b964a6f6aaf8a696a8b70836483fbf25cbb2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0I0OjIyNkY1OTpDRjkyNzoxMTdENTA6Njk2RTA3RUUiLCJ2aXNpdG9yX2lkIjoiNTU5ODQwMzEyNjY1MDM0MTM1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ac08fcdd2f8e63431e549731c246ffad77c46bdd04e214ce34dde9c618ad56d3 |
| hovercard-subject-tag | issue:1150311753 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular.js/17181/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b9ec422cd1ed78944d963b1013719a20a2658e73b726e483984aaeac8be047e5/angular/angular.js/issues/17181 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b9ec422cd1ed78944d963b1013719a20a2658e73b726e483984aaeac8be047e5/angular/angular.js/issues/17181 |
| og:image:alt | I suppose this doesn't meet the LTS definition of a critical bug. But I am going to file it here in case it is - at the very least - helpful to other people. I spent a lot of time tracking down thi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | BigBadaboom |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b5131b207ddd175abf059a848d5f4302ec0606b02211b989013be49cf08593e |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular.js git https://github.com/angular/angular.js.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 460078 |
| octolytics-dimension-repository_nwo | angular/angular.js |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 460078 |
| octolytics-dimension-repository_network_root_nwo | angular/angular.js |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f8590a63bfc8093b241930ca57d536c9a50f9680 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width