Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngOptions removeUnknownOption() doesn't work right in mobile browsers #17168

Closed
jeremyml opened this issue Dec 30, 2021 · 2 comments
Closed

ngOptions removeUnknownOption() doesn't work right in mobile browsers #17168

jeremyml opened this issue Dec 30, 2021 · 2 comments

Comments

@jeremyml
Copy link

jeremyml commented Dec 30, 2021

I'm submitting
This may be an issue caused by a new browser version

Current behavior:
When using Select as in the ngOptions expression for an array of objects (a collection), the first empty option is not removed after the first selection of an option occurs. Subsequent selections also do not remove the empty option. This lingering empty option causes the indexing of the options to be off by 1. For example, if the user selects option 3, then option 4 is selected in the model and option 4 is displayed in the select element. If the user selects the empty option, then the first object in the collection is selected (instead of the lingering empty option). If the user selects the last option, then no option is selected (presumably because the indexing error tries to select an object after the last element in the array).

As a workaround I edited the anguar.js file in version 1.8.2 to comment out line 35304 which removes the unkownOption.

  self.removeUnknownOption = function() {
    if (self.unknownOption.parent()) self.unknownOption.remove();  // I commented out this line
  };

Removing this line keeps the unknown option in the options list, and this precludes the indexing problem. Of course, it also causes the unknown option to never be removed.

Expected / new behavior:
I expect the unknown option to be removed after the user selects an option for the first time. Until a few months ago this worked.

Minimal reproduction of the problem with instructions:
Unfortunately this may be difficult to reproduce, because it only occurs on SOME mobile devices. My iPhone 12 uses the same version of Chrome and does not have this behavior. But my iPad Pro on the same version of Chrome does have the behavior. The behavior occurs in our production app on many iPads in the field using Safari and Mobile Chrome. Users report this did not always occur until several months ago.

This never seems to occur on the Windows Chrome browser of any version tested. Only mobile.

AngularJS version: 1.8.2

Browser: Mobile Chrome 96.0.4664.116 and Safari on iOS v15.1

Anything else:
I suppose it is possible the browser is running out of memory, and maybe the lack of resources on the mobile device could cause the unkownOption to never be removed.

@jeremyml
Copy link
Author

I realize AngularJS v1.8.2 is ending support soon, but we submitted this request a few days before the EOL deadline. :) Seriously though, any advice on hos to handle this would be great as we will not be able to upgrade to Angular for a little while.

@gkalpak
Copy link
Member

gkalpak commented Jan 24, 2022

Thx for reporting this, @jeremyml. As you said, AngularJS is End-Of-Life now, so no more fixes will be published.
Unfortunately, I don't what might be causing the behavior you described (as I don't have access to an iPad).

I am going to close the issue, but if you find the root cause or a work-around, feel free to post it below to help others that might also run into the same problem.

@gkalpak gkalpak closed this as completed Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants