Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORL-1334] Keyboard shortcuts #3158

Merged
merged 15 commits into from Sep 2, 2020
Merged

Conversation

nick-funk
Copy link
Contributor

@nick-funk nick-funk commented Sep 1, 2020

What does this PR do?

Allows you to use the C and Shift + C key to traverse through the comment stream.

Changes to schema?

None

How to test

  • Go to All Comments in stream
  • Press C to traverse through visible comment tree
  • Press Shift + C to reverse traverse through comments

@kgardnr kgardnr added this to the v6.3.5 milestone Sep 1, 2020
@nick-funk nick-funk force-pushed the feature/CORL-1334-keyboard-shortcuts branch from 7d325cf to 1f43ab9 Compare September 1, 2020 19:07
@nick-funk nick-funk force-pushed the feature/CORL-1334-keyboard-shortcuts branch from 3e22d70 to 63067b3 Compare September 1, 2020 21:38
@nick-funk nick-funk marked this pull request as ready for review September 1, 2020 21:43
@@ -15,7 +15,7 @@ export const defaultPymControlFactory: PymControlFactory = (config) =>
new PymControl(config);

export default class PymControl {
private pym: pym.Parent;
public pym: pym.Parent;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert to private as it doesn't seem it's used elsewhere.

@@ -167,6 +168,8 @@ export class StreamEmbed {
decorators: streamDecorators,
url,
});

hookUpWindowEvents(this.pymControl);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the existing streamDecorators array above and rewrite the hookUpWindowEvents as a decorator so it supports a unsubscribe function.

See https://github.com/coralproject/talk/blob/master/src/core/client/embed/decorators/withClickEvent.ts for an example.

}, []);

const toKeyStop = useCallback((el: Element) => {
const id = el.attributes.getNamedItem("data-keyid");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Data attributes can be retrieved instead via:

el.dataset.keyid

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that you must use HTMLElement instead of Element here to allow this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that if you rewrite access for data attributes to use kebab case, access via .dataset is done via camel case:

el.dataset.isLoadMore

@@ -264,6 +266,8 @@ export const AllCommentsTabContainer: FunctionComponent<Props> = ({
disabled={isLoadingMore}
aria-controls="comments-allComments-log"
className={CLASSES.allCommentsTabPane.loadMoreButton}
data-keystop={true}
data-isLoadMore={true}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Data props typically are written in kebab case:

data-key-stop
data-is-load-more

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that there is a convention.
aria props does not separate words:

aria-labelledby
aria-describedby

either way is fine for me though.

@wyattjoh wyattjoh force-pushed the feature/CORL-1334-keyboard-shortcuts branch from 63067b3 to 9ec30b9 Compare September 2, 2020 15:22
@wyattjoh wyattjoh added the 🚀 merge it! Pull requests that should be merged after status checks pass with a review label Sep 2, 2020
@kodiakhq kodiakhq bot merged commit bcf6c9d into master Sep 2, 2020
@kodiakhq kodiakhq bot deleted the feature/CORL-1334-keyboard-shortcuts branch September 2, 2020 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 merge it! Pull requests that should be merged after status checks pass with a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants