Giter Site home page Giter Site logo

iron-behaviors's People

Contributors

aomarks avatar atotic avatar bartolom avatar bicknellr avatar blasten avatar cdata avatar danbeam avatar dependabot[bot] avatar dfreedm avatar e111077 avatar frankiefu avatar garlicnation avatar jklein24 avatar jscissr avatar keanulee avatar mgiuffrida avatar notwaldorf avatar rictic avatar rslawik avatar samuelli avatar tedium-bot avatar tjsavage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iron-behaviors's Issues

iron-control-state: add tabindex to hostAttributes

I'm assuming the point of iron-control-state is to make an element "focusable". If that's true, then the element must have a tabindex attribute. Otherwise, the browser does not consider the item focusable and won't fire the focus event. Knowing that, shouldn't elements implementing iron-control-state always have a tabindex attribute? Or is this omitted on purpose?

drop polymer-legacy

is it possible to drop polymer-legacy dependency ? it's really bloating bundles

and I also noticed

import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';

is not used, can we safely delete it ?

Make _asyncClick easier to test, or provide a test helper

MockInteractions.pressAndReleaseKeyOn uses Polymer.Base.async to queue the keyUp event.

IronButtonState._asyncClick uses this.async to queue the click event, with a delay of 1.

This means test code has to do this:

MockInteractions.pressEnter(foo);
Polymer.dom.flush();  // flush MockInteraction's async call
foo.async(function() {
  // test foo
}, 1);  // schedule a setTimeout with a delay >= 1, so it runs after _asyncClick

The async call must have a delay greater than or equal to the one used in _asyncClick thanks to step 13. If you ever change the delay here, say from 1 to 10, my test code will fail.

(The Polymer.dom.flush() in the above is extraneous, but included for clarity.)

It would be nice if I could just do:

MockInteractions.pressEnter(foo);
Polymer.dom.flush();  // flush all the things
// test foo

or even:

MockInteractions.pressEnter(foo);
Polymer.dom.flush();  // flush MockInteraction's async call
Polymer.dom.flush();  // flush IronButtonState's async call
// test foo

so I don't have to hard-code constants and keep them up-to-date with _asyncClick.

IronControlState _focusBlurHandler not handling focus events of slotted elements.

Description

In Polymer 3 , when a component using iron-control-state behavior has a slotted component that raises a 'focus' event, the parent component's focused property is set. This traps the focus on the _focusableElement in components using paper-input-behavior like 'paper-input'.

Example :

<paper-input label="username">
  <paper-icon-button slot="suffix" icon="clear"></paper-icon-button>
</paper-input>

The user is not able to move the focus to the paper-icon-button using the tab key, as the 'input' gets focused due paper-input-behavior.

Fix could involve checking the event.target before updating the focused property of the component.

_focusBlurHandler: function(event) {
   // Polymer takes care of retargeting events in shadowRoot.
   if(event.target === this){
      this._setFocused(event.type === 'focus');
   }
   return;
}

This issue seems to be the cause of paper-input issue #631.

Expected outcome

Slotted element's focus and blur events should not affect the component.

Actual outcome

Slotted element's 'focus' event sets focused property in the component.

Live Demo

Paper input demo page. Section Inputs can have prefixes and suffixes

Steps to reproduce

Available in paper-input issue #631.

Browsers Affected

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10

2.0 Code cleanup

  • remove default values for properties (this will require changes in elements that use these defaults for styling, like paper-checkbox

Allow keyBindings to be set on elements

Description

Currently keyBindings are decided by behaviors but for example for a <paper-radio-button> it is necessary to allow to directly set key-bindings on the element.

IronButtonState: code review

  • pointerDown, receiveFocus... and _mouseEventRe should be proper private, and not defined in the properties block
  • should import iron-control-state.html

IronControlState: code review

  • IronControlState needs better docs
  • [disabled] is pretty bonkers on IE (ask @kevinpschaaf for more details)
  • private properties shouldn't be pre-defined in the properties block
  • need to revisit the focus/blur code

Setting paper-button disabled doesn't remove it from tab sequence.

Description

Setting paper-button disabled doesn't remove it from tab sequence.

The reason seams to be in iron-control-state.html where tabIndex is set to -1. This works if it's set statically, but this doesn't work when set dynamically. What seems to work in Chrome is to remove the tabIndex attribute from the element.

Expected outcome

When the button disabled attribute is set, it should be neither clickable nor accessible by tabbing.

Actual outcome

When put on dialog, the button can be accessed by tabbing, ripple works, can close the dialog.

Live Demo

https://jsbin.com/quwadiwula/edit?html,css,js,output

Steps to reproduce

In the demo:

  1. When dialog opens, click on the dialog.
  2. When button disables, press tab
  3. Press space

Browsers Affected

  • Chrome (v51)

controls shouldn't change value when disabled

In 0.9/0.8, setting a control with both of the iron-behaviors to disabled = true results in the active property being set to false, which ends up changing the value of the controls which use these behaviors.

paper-radio-button, paper-checkbox, paper-toggle-button all rely on the active property to show the state of the control. The active property is changed by iron-button-state in _controlStateChanged when disabled is set to true. This happens because iron-control-state has an observer on disabled which calls _changedControlState.

The result is that if a checked checkbox (radio-button, toggle-button) is disabled, it is also unchecked. I would have to write my own helper function to handle disabled changing:

function disabledChanged(control) {
  // make sure this is called after _changedContolState
  setTimeout(function() {
    var checked = control.checked;
    control.disabled = true;
    control.checked = checked;
  });
}

But that shouldn't be necessary. The behavior of native HTML input controls is to retain the input value when the control is disabled.

Tab order problem

Description

Toggling disabled property removes an element completely from the tab order.

Expected outcome

Reverting disabled = false re-adds the element to the tab order.

Actual outcome

Reverting disabled = false leaves tabindex="-1" on the element and it prevents the children in the shadow tree from getting focus.

Live Demo

http://jsbin.com/perubocupi/edit?html,js,output

Steps to reproduce

Steps are in the demo

Browsers Affected

  • [โœ”] Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10

Differentiate mouse from keyboard focus

The old core-focusable mixin had this section for differentiating between mouse and keyboard focus. This is really helpful behavior that we used quite a lot on the I/O site. Reading the source of iron-button-state and iron-control-state I don't see the same behavior, is it still part of these mixins?

Click/enter on controls inside a checkable widget shouldn't check the widget

https://jsfiddle.net/u5m3zgxx/1/

In Chrome, clicking (or pressing Enter) on a <button> or <a> inside of a <label> for an <input> does not check the corresponding <input>.

Elements like paper-checkbox and paper-radio-button do not behavior this way; tapping the button will check the checkbox/radio-button.

Just using a <label> around a <paper-checkbox> instead of putting the content directly inside the <paper-checkbox>'s light DOM isn't great because the styling is different.

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.