taufik-nurrohman / tag-picker

Better tags input interaction with JavaScript.
http://taufik-nurrohman.js.org/tag-picker
MIT License
28 stars 3 forks source link

IE: Persistent Placeholder #5

Closed lorraineS closed 7 years ago

lorraineS commented 7 years ago

On IE11 if our input has a placeholder, the plugin will convert this placeholder into a string, this will create an unwanted behavior since the placeholder will become a tag.

<input type="search" id="tags" placeholder=« My placeholder »>

  config = {
    join: ', ', 
    max: 5,
    alert: false,
    update: function() {}
  };

  var foo = new TIB(document.querySelector('input[id="tags"]'), config);
  foo.create();

capture d ecran 2017-05-03 a 12 03 00

A first idea to fix this is to add values: [''] in the config object. That fixes the problem but that creates a second one: the placeholder remains after a first tag is created.

  config = {
    join: ', ', 
    values: [''], // empty values
    max: 5,
    alert: false,
    update: function() {}
  };

capture d ecran 2017-05-03 a 12 10 08 2

The result on your demo: http://codepen.io/anon/pen/GmvgRp (IE11 or less !)

capture d ecran 2017-05-03 a 12 22 39 2

taufik-nurrohman commented 7 years ago

I’m affraid that I can’t fix this issue by myself due to the limitation of the environment. But currently, the placeholder itself is also just a fake placeholder that is generated by the placeholder attribute on a contenteditable element (tags-input-beautifier.css#L47&L54). Thinking that IE can convert pseudo elements into a valid form value seems impossible for me. I see that you are using something like Google Material framework? Do you have some script that behaves like placeholder polyfill? If so, maybe that’s the cause.

I can produce the second capture from my environment, but only for the first tag:

t-i-b bug

lorraineS commented 7 years ago

No, i use my own styles. No framework. I will keep you informed if i find a fix.

taufik-nurrohman commented 7 years ago

Tested on IE11.

t-i-b fix