manolo / gwt-polymer-elements

Polymer Web Components for GWT. A collection of Material Design widgets for desktop and mobile.
Apache License 2.0
155 stars 49 forks source link

Workaround to show yellow underline for tabs #31

Closed amahdy closed 9 years ago

amahdy commented 9 years ago

Review on Reviewable

amahdy commented 9 years ago

Code by @tomivirkki

manolo commented 9 years ago

I don't like this approach since it does not fix the component for it's usage in gwt projects, it's just for demo. There is a new feature in generator, so if you have a PaperTabsBase.java in the folder lib/[papert-tabs-namespace] then PaperTabs.java would extend it instead of PolymerWidget which should be extended by the PaperTabsBase. in PaperTabsBase we could override the onAttach call and do the hack.


Review status: 0 of 1 files reviewed at latest revision, all discussions resolved, all commit checks successful.


Comments from the review on Reviewable.io

amahdy commented 9 years ago

Adding PaperTabsBase.java under lib/com/vaadin/polymer/paper/widget works as expected.

Tried this code and didn't work:

package com.vaadin.polymer.paper.widget;

import com.google.gwt.core.client.JavaScriptObject;
import com.vaadin.polymer.PolymerWidget;
import com.google.gwt.user.client.Element;

public class PaperTabsBase extends PolymerWidget {

    public PaperTabsBase(String tag, String src, String html) {
        super(tag, src, html);
    }

    @Override
    protected void onAttach() {
        super.onAttach();

        fixTabsSelection(this.getElement());
    }

    // A temporary workaround to fix the underline tab issue
    // Not a solution.
    private native void fixTabsSelection(Element element) /*-{

      element._onResize();
    }-*/;
}

Browser gives: element_0_g$._onResize is not a function

cwayfinder commented 9 years ago

Fixed in https://github.com/vaadin/gwt-polymer-elements/pull/37

manolo commented 9 years ago

37 partially fixes this. So we need both.