nexushoratio / userscripts

Random userscripts for browsers.
GNU General Public License v3.0
2 stars 0 forks source link

Support `Messaging` view #144

Closed nexushoratio closed 11 months ago

nexushoratio commented 1 year ago

https://www.linkedin.com/messaging

Unlikely to support anything for crafting messages.

nexushoratio commented 1 year ago

The UX for Messaging is unlike any other Page we have dealt with before. Not surprising really.

nexushoratio commented 1 year ago

After the little bit of reading I've done on ARIA, particularly around tabs, I recognize some of what is happening on the Messaging view, that also happens on the MyNetwork/InvitationManager page.

The Focused|Other split (or Received|Sent) are <button>s with the role=tab attribute inside a <div role=tablist> (Also see #123 for some background.) In both cases, if a button has focus, then the left/right arrow keys (with or without modifiers) become active to navigate to the next tab in sequence (with wrapping). But, that only happens if those buttons have focus. Tab off of them, and the magic stops (also, only one button in the tablist has tabindex=0 at a time, the rest of the time it is -1. Related, the active button also gets the aria-selected=true attribute).

Anyway, despite the fact that both use the arrow keys to navigate, implementations are different. With InvitationManager, it goes to a different page. In Messaging, it does a major rewrite on the contents of what could be called the role=tabpanel element (if they actually used one).

It is not yet clear of the arrow key support for navigating the tabs comes from the browser or the app. More research is needed. But, it is clear that it is only active during focus. Only one member of the tablist is allowed to take focus at a time, so the tablist becomes the tab stop for tabbing (overloading the word tab here to mean both tabs in a widget, and the act of using the TAB key to navigate, as with old fashioned typewriter tab-stops).

So now that we understand what is happening, how can we make it better? If a user goes back and forth between the tables, which in this case both happen to be scrollable lists, do we try to maintain state for them? In the InvitationManager case, if the user does not notice that those are separate web pages, the UX would be that LIT maintains current active. Do we do the same here?

nexushoratio commented 12 months ago

Interesting gotcha: Whenever a new conversation is selected (either via keyboard, or via click), the focus immediately goes to the Write a message... text area. This means that navigating through conversations would require j TAB j TAB and so on.

nexushoratio commented 11 months ago

Working around the focus on the message box issue is not as trivial as I had hoped.

Scroller.#scrollBy() first resets the current item with this.item = this.item, which sends one change event, even though it is a no-op. Then, lines later, calls this.item = item to set it to the new item, which sends change again.

Oddly, in the callback, a randomly placed this.convoCards.item solves the problem. That is, invoking the getter interferes somehow, probably because it is mid-state change.

Maybe this information will lead to something interesting.

Hmmm.... seems the above working around the problem is inconsistent.

Ignore this whole comment. Has nothing to do with tracking down the bug or fixing it. Just some page loads get into a state that regularly triggers it, and some do not.

Not to say nothing was learned from this observation: Triggered twice may still be related. Just not calling back into Scroller.

I think I can reproduce this:

  1. Click on message box giving it focus
  2. TAB out of box
  3. Navigate

Focus is now back in the message box, but it does not have the data-artdeco-is-focused attribute. Actually, it seems like that attribute is pretty undependable.

Once in the above state, it seems to stay there. It appears that clicking on a convo card will fix the issue.

Obviously, this is annoying, but since we appear to have a work around, it can probably be ignored for the moment. Maybe as we add more to the page, we can find a way to address this other than an onFocus handler.