Keyboard/mouse mode and keyboard support bugfixes

This commit is contained in:
Scott Nonnenberg
2019-11-21 11:16:06 -08:00
committed by Ken Powers
parent ed55006f20
commit 2a0a73cfc1
25 changed files with 686 additions and 274 deletions

View File

@@ -18,12 +18,6 @@ export type OwnProps = {
export type Props = OwnProps;
function focusOnRender(el: HTMLElement | null) {
if (el) {
el.focus();
}
}
export const StickerManager = React.memo(
// tslint:disable-next-line max-func-body-length
({
@@ -36,6 +30,7 @@ export const StickerManager = React.memo(
uninstallStickerPack,
i18n,
}: Props) => {
const focusRef = React.createRef<HTMLDivElement>();
const [
packToPreview,
setPackToPreview,
@@ -48,6 +43,14 @@ export const StickerManager = React.memo(
knownPacks.forEach(pack => {
downloadStickerPack(pack.id, pack.key);
});
// When this component is created, it's initially not part of the DOM, and then it's
// added off-screen and animated in. This ensures that the focus takes.
setTimeout(() => {
if (focusRef.current) {
focusRef.current.focus();
}
});
}, []);
const clearPackToPreview = React.useCallback(
@@ -76,11 +79,7 @@ export const StickerManager = React.memo(
uninstallStickerPack={uninstallStickerPack}
/>
) : null}
<div
className="module-sticker-manager"
tabIndex={-1}
ref={focusOnRender}
>
<div className="module-sticker-manager" tabIndex={-1} ref={focusRef}>
{[
{
i18nKey: 'stickers--StickerManager--InstalledPacks',