Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This solution is a bit hackish, but it should provide a working solution to anyone else who encounters this issue.</p> <p><code>.color-picker</code> (which is the div to be expanded) has a <code>tabindex</code> attribute that allows it to be focused, and <code>onfocus</code> it calls a function that adds the class <em>focus</em> to the element in question. Furhtermore, the function also creates an empty div with the class <code>close-color-picker-overlay</code>. That div has:</p> <ul> <li>A <code>position: fixed</code> with <code>bottom</code>, <code>left</code>, <code>right</code> &amp; <code>top</code> styles all set to 0, making the div cover all of the page. </li> <li>A <code>z-index</code> style 1 less than <code>.color-picker.focus</code>'s </li> <li>A <code>tabindex</code> attribute 1 more than <code>.color-picker</code>.</li> </ul> <p>This means that as soon as the user clicks outside of the <code>.color-picker</code> or focuses on something else (eg. by clicking tab), <code>.close-color-picker-overlay</code> receives focus. For that very event, there's an event listener that runs a <code>querySelector</code> for <code>.color-picker.focus</code> and removes the class <em>focus</em> from the element it finds. Then it removes <code>.close-color-picker-overlay</code> from the DOM, resetting everything to the original state.</p> <p>This way, focusing the input element nested within <code>.color-picker</code>, doesn't interfere with anything.</p> <p>I also made <a href="http://jsfiddle.net/leopld/RZ3Rg/" rel="nofollow">a JSFiddle</a> to more clearly illustrate how I went about hacking this problem (should anyone ever encounter a similar one).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload