Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Lazy Loaded Select Doesn't Set Value #2141

Closed
mrp67 opened this issue Feb 28, 2020 · 4 comments · Fixed by #2125
Closed

Lazy Loaded Select Doesn't Set Value #2141

mrp67 opened this issue Feb 28, 2020 · 4 comments · Fixed by #2125

Comments

@mrp67
Copy link

mrp67 commented Feb 28, 2020

Describe the bug
When list items are lazy loaded, when clicking on a value, the select menu appears to still be empty.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the Lazy Load section of the Mdc Select section of the demo.
  2. Click on the "load" button
  3. Select a value
  4. No value will be populated and select menu will remain empty

Expected behavior
Clicking on a value should populate the select menu and set the form value, just like the non-lazy loaded ones.

Screenshots
If applicable, add screenshots to help explain your problem.
image

What Angular MDC version are you using?
This is in the demo which should be using the current latest version. I am also having the same issue on 5.0.5

@mrp67
Copy link
Author

mrp67 commented Feb 28, 2020

I spun up the demo locally with a debug value below the select: {{ lazySelect.value | json }}
It seems that the correct value is set on the form, but the appearance of the select is not updated
image

@mrp67
Copy link
Author

mrp67 commented Feb 28, 2020

I'm not entirely sure if this is how the issue should be fixed, but I was able to fix it by modifying the select's layout function. I'm basically doing what's happening in ngAfterViewInit in the
if (this._initialized) { ... }

Before (not working):

  private layout(): void {
    if (this._initialized) {
      this._selectBuilder();

      if (this._outlined) {
        this._foundation.layout();
      }
    }
  }

After (working):

private layout(): void {
    if (this._initialized) {
      this._asyncBuildFoundation().then(() => {
        this._selectBuilder();
      });

      if (this._outlined) {
        this._foundation.layout();
      }
    }
  }

@k11k2
Copy link

k11k2 commented Mar 2, 2020

@trimox Any update on this ?

@trimox
Copy link
Owner

trimox commented Mar 2, 2020

@AlwaysAbhl001 Resolving as part of #2125. Noticed demo was broken during testing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants