prateekbh / preact-material-components

preact wrapper for "Material Components for the web"
https://material.preactjs.com
MIT License
552 stars 81 forks source link

fix: setLabelRef #1351

Closed ghost closed 4 years ago

ghost commented 4 years ago

There is no setter of labelRef. So labelRef is always undefined, and cannot executive this code:

protected updateSelection() {
      ...

      const selectedIndex = this.MDComponent.selectedIndex;
      if (selectedIndex === 0) {
        if (this.labelRef) {
          this.labelRef.classList.remove('mdc-floating-label--float-above');
        }
      } else {
        if (this.labelRef) {
          this.labelRef.classList.add('mdc-floating-label--float-above');
        }
      }
    }
  }

So I fix it!

before: image

after: image