0

I'm building this custom layout, and I am getting some weird stuff going on with Firefox.

As you can see, the images are not focusable, either by tab or mouse click on Firefox. This works fine on Chrome. They do need to be images, because the final product will be svgs, and they need to be clickable and keyboard accessible both!

Here's a link to my page.

And here's my JS code

if ( jQuery(window).width() > 900) {
//Execute only when width is greater than 900px

 var circles = document.getElementsByClassName("js-circle"),
     text = document.getElementsByClassName("js-text"),
     buttons = document.getElementsByClassName("js-button");

  for (var i = 0; i < circles.length; i++) {
    console.log("assign listeners");
    assignListeners(i);
  }

  function assignListeners(i) {
    (function(i) {
      circles[i].addEventListener('focus', function(e) {
        console.log(circles[i]);
        reveal(e, i);
      }, false);
      buttons[i].addEventListener('blur', function(e) {
        hide(e, i);
      }, false);
    }(i));
  }

  function reveal(e, i) {
    jQuery(text[i]).fadeIn();

  }

  function hide(e, i) {
    jQuery(text[i]).fadeOut();
  }

}
Kathryn Crawford
  • 611
  • 1
  • 10
  • 27

2 Answers2

4

Turns out the issue was not with Firefox, it was with Mac OSX. Apparently if you do not have full keyboard access on in your system preferences, then firefox will not tab to anything that is not a link.

Kathryn Crawford
  • 611
  • 1
  • 10
  • 27
  • 1
    ok a duplicate here i guess http://stackoverflow.com/questions/11704828/how-to-allow-keyboard-focus-of-links-in-firefox/11713537#11713537 :) – G-Cyrillus May 25 '16 at 19:05
1

maybe you can skip the jquery some how if you set an attribute tabindex to img tag and use the css selector +


basicly the img HTML :

<img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg180 || svg-circle || js-circle" tabindex="0">

and the CSS :

img:focus + .text-container {
  display:block;
}

DEMO snippet to run full page

.bg-container {
  width: 100%;
  margin: 0;
  background: linear-gradient(to bottom, #a7a7a7 0%, #dadada 100%);
}
/* neatly spaced stuff for mobile */

.img-container {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.svg-circle {
  background: white;
  border-radius: 50%;
  height: 6em;
  margin-top: 2em;
  width: 6em;
}
.svg-circle:focus {
  background: red;
}
.text-container {
  color: #e92837;
  text-align: center;
  max-width: 15em;
}
.text-container p {
  color: #025a83;
}
.services-button {
  background: #e92837;
  border: none;
  color: #ffffff;
  font-family: Myriad Pro;
  font-size: 18px;
  margin-bottom: 2em;
  padding: 13px 20px 12px 20px;
  text-decoration: none;
}
.services-button:hover {
  text-decoration: none;
}
@media screen and (min-width: 900px) {
  /* centers the image container and constrains proportions */
  .img-container {
    height: 50%;
    margin: 1.75em auto 0;
    min-height: 900px;
    padding: 2.8em;
    position: relative;
    width: 50%;
  }
  /* sets circles up in center of img-container to prepare for translations */
  .svg-circle {
    display: block;
    left: 50%;
    margin: -3em;
    position: absolute;
    top: 50%;
  }
  /* positions all text containers in the center of the img-container */
  .text-container {
    display: none;
    left: 0;
    margin-left: auto;
    margin-right: auto;
    margin-top: 10em;
    max-width: 15em;
    position: absolute;
    right: 0;
  }
  /* TRANSLATIONS */
  .deg0 {
    transform: translate(23em);
  }
  .deg30 {
    transform: rotate(-30deg) translate(23em) rotate(30deg);
  }
  .deg60 {
    transform: rotate(-60deg) translate(24em) rotate(60deg);
  }
  .deg90 {
    transform: rotate(-90deg) translate(25em) rotate(90deg);
  }
  .deg120 {
    transform: rotate(-120deg) translate(24em) rotate(120deg);
  }
  .deg150 {
    transform: rotate(-150deg) translate(23em) rotate(150deg);
  }
  .deg180 {
    transform: rotate(-180deg) translate(23em) rotate(180deg);
  }
}
img:focus + .text-container {
  display: block;
}
<div class="bg-container">
  <div class="img-container">
    <img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg180 || svg-circle || js-circle" tabindex="0">

    <div class="text-container || js-text">
      <h2>Service 1</h2>
      <p>I don't know what you're talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan--</p>
      <button class="js-button" type="button">Learn More</button>
    </div>

    <img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg150 || svg-circle || js-circle" tabindex="0">

    <div class="text-container || js-text">
      <h2>Service 2</h2>
      <p>I don't know what you're talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan--</p>
      <button class="js-button" type="button">Learn More</button>
    </div>

    <img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg120 || svg-circle || js-circle" tabindex="0">

    <div class="text-container || js-text">
      <h2>Service 3</h2>
      <p>I don't know what you're talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan--</p>
      <button class="js-button" type="button">Learn More</button>
    </div>

    <img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg90 || svg-circle || js-circle" tabindex="0">

    <div class="text-container || js-text">
      <h2>Service 4</h2>
      <p>I don't know what you're talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan--</p>
      <button class="js-button" type="button">Learn More</button>
    </div>

    <img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg60 || svg-circle || js-circle" tabindex="0">

    <div class="text-container || js-text">
      <h2>Service 5</h2>
      <p>I don't know what you're talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan--</p>
      <button class="js-button" type="button">Learn More</button>
    </div>

    <img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg30 || svg-circle || js-circle" tabindex="0">

    <div class="text-container || js-text">
      <h2>Service 6</h2>
      <p>I don't know what you're talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan--</p>
      <button class="js-button" type="button">Learn More</button>
    </div>

    <img tabindex="0" src="http://kathrynjcrawford.com/testimg.png" class="deg0 || svg-circle || js-circle" tabindex="0">

    <div class="text-container || js-text">
      <h2>Service 7</h2>
      <p>I don't know what you're talking about. I am a member of the Imperial Senate on a diplomatic mission to Alderaan--</p>
      <button class="services-button || js-button" type="button">Learn More</button>
    </div>

  </div>

</div>

Looks much less buggy to me at this point from what chrome renders :)

G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
  • Well, Firefox ignores the :focus selector, so no, this doesn't work either. – Kathryn Crawford May 25 '16 at 14:36
  • @KathrynCrawford :focus selector without tabindex doesn't work (only on links or form elements), the snippet works with FF. do you have an example where it doesn't work ? beside snippet i created with Firefox wich works (i played with :focus and tabindex for a few years ) ? – G-Cyrillus May 25 '16 at 15:06
  • @KathrynCrawford http://dabblet.com/gist/2906473 an experimental 2 level menus via tabindex and :focus (no js at all) made with FF & almost 5 years ago ... works on click or tab key – G-Cyrillus May 25 '16 at 15:13
  • see my answer. It wasn't firefox actually causing the problem. It was Mac OS system preferences... – Kathryn Crawford May 25 '16 at 18:11
  • @KathrynCrawford actually, the OP's javascript code only worked with my chrome and Opera, not firefox :) (WIN OS) – G-Cyrillus May 25 '16 at 18:18
  • I am the OP. It's working fine now if you tab to it. Still working on clicking. Firefox does not acknowledge the css :focus selector on click. – Kathryn Crawford May 25 '16 at 18:38
  • wich is the code that do not take the click ? JS or HTML/CSS snippet . as you noticed, i'm confused :) – G-Cyrillus May 25 '16 at 18:43
  • Sorry, on either my page or your example whatever code is under the css :focus selector is not firing in Firefox in Mac OS. So, for my example, the background color does not change to red, and in yours nothing works at all. Everything works fine if you tab to the images, but clicking does not work at all. – Kathryn Crawford May 25 '16 at 18:58
  • The issue with Firefox not being able to tab to the images at all, however, was a Mac OS system preferences issue, not a browser issue. – Kathryn Crawford May 25 '16 at 18:58
  • @KathrynCrawford oh strange, it is at least html 4 and css 2.1 even earlier .... sorry i do not run this OS, i won'nt be any help to debug this – G-Cyrillus May 25 '16 at 18:59
  • That's ok! Thanks for your help anyways. It's a weird fluke for sure. Caniuse.com says Firefox has full support, but apparently there's a couple quirks. – Kathryn Crawford May 25 '16 at 19:05