wysihtml5 icon indicating copy to clipboard operation
wysihtml5 copied to clipboard

Styles are not applied correctly on an iframe replacing a textarea with the required attribute

Open adg29 opened this issue 12 years ago • 4 comments

In my code I've added a required attribute to the textarea in the example that comes with the download. <textarea id="textarea" placeholder="Enter text ..." required></textarea>

Doing so exposed some unexpected behavior of the functionality that applies styles form the textarea to the iframe containing the wysihtml5 editor. The problem I'm seeing is that even though the editor has content, it is always being styled as if it was in an error state.

I dug in, and basically, it seems that only the initial styles are copied from the text area element to the iframe. This means that the iframe is styled only with the values associated with the required and invalid pseudo classes. Or seen from another perspective, the styles associated with required and valid pseudo classes are never applied to the iframe. Below you'll see the CSS that can be used to address the different states of a textarea with the required attribute-- invalid, invalid with focus, and valid.

Also attached is a screenshot of the editor with valid content but the invalid styling.

<style>
textarea:required:invalid,
input:required:invalid{
    border: 1px solid orange;
}
input:focus:required:invalid:focus,
textarea:focus:required:invalid:focus 
{
    border: 1px solid red;
}
textarea:focus:required:valid:focus,
input:focus:required:valid:focus{
    border: 1px solid green;
}
</style>

Screenshot of the editor with valid content but invalid styling.

adg29 avatar May 01 '12 20:05 adg29

I think this is a valid usecase. @tiff we would have to allow the required attribute on the textarea and observe the HTML5 invalid event. :) Or observe for a change and then sync the styles from the textarea to the iframe

ingochao avatar May 31 '12 22:05 ingochao

Has there been any progress on this? I'm experiencing the same exact issue. Thanks!

darogina avatar Sep 27 '12 02:09 darogina

I have the same problem. Is there anyone who can help how to fix it? Thanks

TinaJ avatar Jul 17 '13 16:07 TinaJ

Has it been fixed? I faced with the same problem when I add new class to textarea, but iframe css properties are not changing. Should I call any specific method for synchronization?

KoulSlou avatar Mar 08 '16 17:03 KoulSlou