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

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

@jeremyml

Description

@jeremyml

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions