Skip to content

bug(MatSelectHarness): getOptions() returns results from another harness #19468

@mischkl

Description

@mischkl

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue

Steps to reproduce:

  1. Add two mat-selects with the same selector (e.g. id="test") but different ancestor selectors to a page. Both should be multiple-selects. Add 3 options in the first select and no options in the second.
  2. Write code that sets options of second select whenever selection within first select changes, so that the second select always contains only the options that are selected in the first select.
  3. Use test harness to click one option in first select, then use following code on the second test harness to check that only the single option is available:
    await select.open();
    const optionLabels = Promise.all((await select.getOptions()).map(option => option.getText()));

Expected Behavior

What behavior were you expecting to see?

  • There should only be one option in the second select.

Actual Behavior

What behavior did you actually see?

  • The options returned by the second select are the same as in the first - i.e. 3 options - even though when inspecting the component instance, I have verified that the options are correct (just one option).

Environment

  • Angular: 9.1.7
  • CDK/Material: 9.2.3
  • Browser(s): Chrome v80
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS 10.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: material/selectneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions