Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Draft: Add jump to date functionality to date headers in timeline #7317

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Dec 9, 2021

Add jump to date functionality to date headers in timeline

Fix element-hq/element-web#7677

Part of MSC3030: matrix-org/matrix-spec-proposals#3030

Experimental Synapse implementation added in matrix-org/synapse#9445

Dev notes

Combining React callback refs and ref-refs,

const attachRef = (input) => {
    this.input = input;

    if (typeof this.props.inputRef === 'function') {
        this.props.inputRef(input);
    } else if(this.props.inputRef) {
        this.props.inputRef.current = input;
    }
}

TODO

  • Refactor rest of MenuItems
  • Clean up PR

This PR currently has no changelog labels, so will not be included in changelogs.

A reviewer can add one of: T-Deprecation, T-Enhancement, T-Defect, T-Task to indicate what type of change this is, or add Type: [enhancement/defect/task] to the description and I'll add them for you.

Preview: https://61b30b58b34514d9ad23d6d6--matrix-react-sdk.netlify.app
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.

@MadLittleMods MadLittleMods requested a review from a team as a code owner December 9, 2021 09:40
@MadLittleMods MadLittleMods marked this pull request as draft December 9, 2021 09:40
@MadLittleMods MadLittleMods removed the request for review from a team December 9, 2021 09:40
@@ -50,21 +50,21 @@ limitations under the License.
}

// round the top corners of the top button for the hover effect to be bounded
&:first-child .mx_AccessibleButton:first-child {
&:first-child .mx_AccessibleButton:not(.mx_AccessibleButton_hasKind):first-child {
Copy link
Contributor Author

@MadLittleMods MadLittleMods Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid style clashes when trying to put a primary accessible button inside of a ContextMenu

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a reason not to do that, it won't be accessible for keyboard-only users. Context Menus have strict focus management requirements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(new better flow suggestions welcome) 🙂

Popping off to a modal feels a little heavy.

Tabbing to a date picker in the context menu seems in the realm of sane to handle for the keyboard. But the HTML5 date picker here isn't giving the best UX because ideally we could remove the "Go" button and "Go" automatically when a date is picked. This doesn't seem feasible though because there no way to distinguish a change from navigating the months of the picker vs a final selection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab in a context menu closes the context menu though as it is focus-locked

Copy link
Contributor Author

@MadLittleMods MadLittleMods Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this work. And seems acceptable under ARIA guidelines:

  • Tab: Moves focus to the next element in the tab sequence, and if the item that had focus is not in a menubar, closes its menu and all open parent menu containers.

  • Shift + Tab: Moves focus to the previous element in the tab sequence, and if the item that had focus is not in a menubar, closes its menu and all open parent menu containers.

-- Menu or Menu bar -> Keyboard Interaction, https://www.w3.org/TR/wai-aria-practices/#keyboard-interaction-12


I had this mostly working in 9fa980c except for closing the menu, but Tab was navigating the items as expected.

I think I will try to adapt this to use the RovingTabIndex like the TODO comment in ContextMenu mentions so I can register the items explicitly for navigation and be able to tell when we tab out the end or the start to close the menu.

Copy link
Contributor Author

@MadLittleMods MadLittleMods Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a RovingTabIndex example that is known working and well implemented that I can base this off of? The spaces panel and room list seems like a pretty similar thing with the tree view being navigable with arrow keys and can Tab to the space options of each as you go.

The MessageActionBar which uses Toolbar and RovingTabIndex seems broken as I can't figure out how to navigate by Tab or Arrow keys in it.

It also seems counter-intuitive to me that I'm unable to navigate menus by Tab and have to use Arrow keys but it also seems inconsistent 🤔. Both seem like they should work.

What's the goal of setting tabindex="-1" on elements which are focusable? Maybe to get around focus holes in the page with lots of elements? It doesn't seem as applicable in a ContextMenu which has to be explicitly opened and will close when tabbed out of though.

Copy link
Member

@t3chguy t3chguy Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also seems counter-intuitive to me that I'm unable to navigate menus by Tab and have to use Arrow keys but it also seems inconsistent 🤔. Both seem like they should work.

What's the goal of setting tabindex="-1" on elements which are focusable?

See https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets Technique 1

It is so the app doesn't have a million tabstops, and instead each widget is a tabstop with sane and expected keyboard & focus management, e.g arrows. The roving & treeview stuff was written to match the wai-aria practices

Switching to roving was asked for by a lot of our a11y community, who have only the keyboard to use the app with and if they have to press tab ten times to get through every menu that just makes any action they want to take that much slower.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MessageActionBar does seem to have regressed.
The space panel, room list, space home are all roving focus managed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7336 fixes MAB, during a refactoring something got missed I think

Copy link
Contributor Author

@MadLittleMods MadLittleMods Dec 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into the fixes for the MessageActionBar! 🌟 I've created a v2 PR, #7339, based off of those fixes and wanting to refactor ContextMenu to use RovingTabIndex so that I can leave this PR untouched in its somewhat working state.

@@ -127,6 +127,7 @@ limitations under the License.
transform 0.25s ease-out 0s,
background-color 0.25s ease-out 0s;
font-size: $font-10px;
line-height: normal;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset line-height so it acts normal regardless of environment (ContextMenu has a very large line-height)

const code = e.errcode || e.statusCode;
// only show the dialog if failing for something other than a network error
// (e.g. no errcode or statusCode) as in that case the redactions end up in the
// detached queue and we show the room status bar to allow retry
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Update comment, copy-paste artifact

This currently works except for closing the menu when you
Tab or Shift + Tab out of the boundaries of the menu.

>  - `Tab`: Moves focus to the next element in the tab sequence, and if the item that had focus is not in a `menubar`, closes its `menu` and all open parent `menu` containers.
>
>  - `Shift + Tab`: Moves focus to the previous element in the tab sequence, and if the item that had focus is not in a `menubar`, closes its `menu` and all open parent `menu` containers.
>
> https://www.w3.org/TR/wai-aria-practices/#keyboard-interaction-12

I'm going to try to migrate this to using the RovingTabIndex which is mentioned
in a TODO comment and will probably make this more sane
@HarHarLinks
Copy link
Contributor

You should probably also add this menu in the room info panel or similar, since unlike in your screenshot the closest date header might be pages and pages back if the room is somewhat active.

@@ -50,21 +50,21 @@ limitations under the License.
}
Copy link
Contributor Author

@MadLittleMods MadLittleMods Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably also add this menu in the room info panel or similar, since unlike in your screenshot the closest date header might be pages and pages back if the room is somewhat active.

#7317 (comment)

@HarHarLinks As separate iterations, the plan is to make the date headers sticky so one is always visible.

And add a slash command /jumptodate 2021-12-10

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

URL for an arbitrary day of history and navigation for next and previous days
3 participants