Code Monkey home page Code Monkey logo

Comments (6)

notwaldorf avatar notwaldorf commented on July 28, 2024

Try using attached instead of ready for setting this.label. Does that work?

from paper-checkbox.

doliver-pulsemining avatar doliver-pulsemining commented on July 28, 2024

No it does not make a difference. The lifecycle of the posted example is:

polymer-test.created()
    paper-checkbox.created()
    paper-checkbox.ready()
    paper-checkbox.attached()
polymer-test.ready()
polymer-test.attached()

The label can only be set in ready or attached of polymer-element (or via a property default value just before ready) all of which occur after the paper-checkbox has been initialized.

The issue as I see it is there is no way to get a bound label on the paper-checkbox unless it already has a value when the paper-checkbox.attached() function is called.

Ideally the paper-checkbox would observe changes to <content></content> but I am not sure that this is possible. Alternatively not hiding the label when it is blank would solve the issue.

from paper-checkbox.

notwaldorf avatar notwaldorf commented on July 28, 2024

@doliver-pulsemining Observing changes to <content> is unfortunately not currently not available -- it requires a feature in the core Polymer library, and it's being worked on as we speak.

A really gross solution (that I should probably refactor out in a protected method) is to manually call this.$.checkbox.attached(). That should update your content correctly.

I will make a PR today to refactor that out in a _updateContents method or something, so that you don't have to call attached() directly (which is weird)

from paper-checkbox.

notwaldorf avatar notwaldorf commented on July 28, 2024

Ah, ugh, the problem is that the this.$.checkboxLabel.hidden was not actually ever getting called, so the fix I mentioned won't work. Working on a proper PR to fix this. Sorry!

from paper-checkbox.

doliver-pulsemining avatar doliver-pulsemining commented on July 28, 2024

Something like this should work:

      _updateContents: function () {
        var trimmedText = Polymer.dom(this).textContent.trim();
        this.$.checkboxLabel.hidden = (trimmedText === '');
        // Don't stomp over a user-set aria-label.
        if (trimmedText !== '' && !this.getAttribute('aria-label')) {
          this.setAttribute('aria-label', trimmedText);
        }
      },
      attached: function() {
        this._updateContents();
        this._isReady = true;
      },

Calling _updateContents from an observer on the label in the parent element will update the hidden status.

from paper-checkbox.

notwaldorf avatar notwaldorf commented on July 28, 2024

That's what I had originally, but it's not actually correct unless you always manually call _updateContents, which is annoying. See the PR description for more details: #50

from paper-checkbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.