Photo of Jamie & Lion

The personal site of Jamie Knight, an autistic web developer, speaker and mountain biker who is never seen far from his plush sidekick Lion. View the Archive

Topics: Autism Development

Focus on :focus

Understanding some of the finer quirks of how :focus works is important to build keyboard accessible stuff. Here are some quick notes on what focus is, how it works and how to force it on elements programatically.

1: What is focus.

I like the sitepoint definition of focus:

This pseudo-class matches any element that has keyboard input focus. Keyboard input focus describes any element that’s ready to receive user input. It can apply to a form control, for instance, or to a link if the user navigates using the keyboard.

This definition is pretty complete, the one thing i would add is that :focus these days can come from more than a keyboard user. Phone trackpoints, Assistive Tech and some game controllers also make use of the focus mechanism.

2: Focus only moves down the tree.

The :focus pseudo selector can only be used on elements which can receive focus and their children.

Lets say you have:

<ul>
    <li>
        <a href="http://google.com">
            <span>Visit Google</span>
        </a>
    </li>
</ul>

If keyboard focus is on the anchor only the :focus rules on the children of the anchor are applied. In the case above thats the nested span.

The :hover pseudo selector works the opposite way, applying the :hover rules to the parents of the element which is being hovered. In the case above, if you hovered on the anchor it would also trigger the :hover styles applied to the li.

3: Forcing focus

In some situations you may wish to force focus on a specific element programatically. For example, we use JS to push focus to the drop-down elements on the iPlayer Radio navigation when your using the keyboard.

Forcing focusing on a normally focusable elements is straight forward. Simply use the .focus() method of the DOM node.

For elements which do not receive focus natively you need to first make the element focusable. You do this by setting the tab-index property to -1.

For more discussion of how and when to force focus take a look at the discussion on stack overflow

I think that should be enough to demystify focus a little. If you have any corrections, contradictions or extra information please feel free to let me know in the comments.

Published: 11 February 2013 | Categories: Permalink

Staying Positive.

I’m a very black and white thinker. Normally I am either feeling good or bad, obsessed or depressed. This is apparently an autism thing but the reason is not really important.

Being black and white introduces a whole ton of issues, the longer I have been employed the longer it has bothered me. The excited optimistic feelings have mostly gone away to be replaced by the expectation of arguments and certain frustration. I have good days and bad days.

The problem is this becomes self fulfilling. The more down on something I am the more likely it is to go wrong. What’s more I can see how it flows through the whole team. If the people above me believe something is flawed or if I present something as flawed to my peers the whole situation gets worse. Someone has to be positive and excited.

I can see entirely why people become down and unoptimistic, but I think for me it seems far more powerful. Whereas many people ‘care less’ or ‘let it go’ I attempt to stop caring and only frustrate myself further.

So, to the point. Accepting which things I cannot change is something I just have to learn to do. To decide how much I care about the battles. I have opinions and beliefs, the trick is in how and when to express them.

As a black and white thinker that makes me want to rebel. To simply say no and if that results in me being fired so be it. The line of thought is that by making a stand I don’t have to deal with grey and I can always say I felt as though I was being honest to what I think.

I’m not sure though. Yes. I could make a stupid stand, get angry and leave. Hell if I really wanted I could fuck up my career big time and let the anger and frustration flow out in one big mess. However that is pointless. Nothing would change.

When I reflect on why I am frustrated and angry it’s because I don’t feel all that positive. By feeling down every time something happens I get worse. Positivity becomes a lost cause.

So, before I do something two stupid I’m going to make a very specific aim to be altogether far more positive. To look at things with optimism and to give it a bash. I won’t be perfect (or even good!) but perhaps I will learn something.

I’m still learning these things. I’m still figuring this stuff out, hopefully writing about it will help others or help me to chart my progress.

Published: 10 February 2013 Permalink

Own the fucking product

Cut the crap. Seriously, just cut the shit which is buggy or unused. Focus on making the core experience great. Good is a low target.

‘Good is better than perfect’ but ‘great’ is better still. Aim for great, don’t aim for ‘good’. For some reasons many product owners seems to loose focus and instead waste resources (time, money, words) on stuff which has failed. It’s not a ‘bet’ if you unwilling to decide what failure looks like.

I believe, simply put, that for a great project you require focus. To provide focus you have to work to remove the crap. Decide what matters most and decide a number which represents appropriate effort for a given feature. If 1% of people use it and it takes 10% of resources then your not being a product owner, your pretending.

Make decisions, revise decisions test and learn. Own the fucking product.

Published: 7 February 2013 | Categories: Permalink

Older Articles

Newer Articles