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

<select> with <option> does not set default option correctly #14916

Closed
@c1moore

Description

@c1moore

The Problem
The expected behavior of <select> when using ngModel is to create a default blank <option> when none of the ngRepeated options match the model, as noted in this issue. However, this seems to occur even when the model matches a valid option.

The Proof
Here is a demo of the bug. It seems the second select option defaults to the only option available, hence the bug does not appear. However, the other 3 examples demonstrate the bug. The first select demonstrates the bug in its simplest form. The third select option uses {{}} in the ngSelected directive to demonstrate that the expression does evaluate to true. The final select shows that the issue remains even when a timeout is used to switch the selected option programmatically.

What is Expected?
If ngSelected evaluates to true, as it does in the sample code, the default empty <option> should not be created. Instead, the dropdown should default to the option that matches the model.

Why?
If the model is set appropriately, obviously there is a default value that should be selected. Maybe the user is visiting this page to update data and the dropdown should be set to the value previously selected. For my use case, the dropdown is tied to the current page number and blank is not a valid page number.

Version/Environment
I am using version 1.4.9. I have tested this and seen the bug in both Firefox and Chrome.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions