5

How Super User (and probably all Stack Exchange sites) handle clicks to preview areas for posts currently being written is confusing and horribly inconsistent:

  • If I click the preview pane for a new answer...

    The page focuses on the associated answer text area, i.e. the input field that is used as source for the preview I just clicked.

    Very useful for longer posts, especially in topics with several answers, since it makes finding the text field trivially easy.

  • If I click the preview pane for an existing post I'm editing inline...

    Nothing happens. The current text area loses focus.

  • If I click the preview pane for a Q&A style answer written parallel to the question...

    The page focuses on the text area for the question?!

    Surely you jest! What's next, focusing the search box?

1 Answer 1

3

Observation:

I'm fairly certain this has to do with the tabindex attribute. When you click a post's preview pane (<div class="wmd-preview">), the focus jumps to the an input box (<textarea class="wmd-input">) with tabindex="101". Unfortunately, this does not always match up with the correct element.

Going in the same order as above:

  1. The answer's input box has a tabindex of 101. Clicking the preview pane moves the focus correctly.

  2. The question and answer both have a tabindex of 81. Clicking the preview pane moves the focus to tabindex="101". This element doesn't exist, so focus is lost!

  3. The question has a tabindex of 101. The answer has one of 103. Clicking the preview for either moves the focus to the question's input box.

I tried to change the tabindex for cases 2 and 3 after the page loaded, but it made no difference. I suspect that the tabindex is only used in a condition when pairing a preview pane to an input box. That is, once the elements are paired via JavaScript, then the tabindex has no meaning.

1
  • 1
    Not the first time tabindex broke something. It's also the cause of completely useless tab navigation once multiple inline editors are visible...
    – Daniel Beck Mod
    Commented May 28, 2012 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .