mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
fix: touch points
This commit is contained in:
1 parent
3ba79b9aca
commit
3902e53bee
2 files changed
+41
-2
No files matched your search
@@ -2,6 +2,7 @@ import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useFocusEffect, useRovingTabIndex } from "react-roving-tabindex";
|
||||
import styled, { css } from "styled-components";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import { s } from "@shared/styles";
|
||||
@@ -48,6 +49,19 @@ function DocumentListItem(
|
||||
const user = useCurrentUser();
|
||||
const [menuOpen, handleMenuOpen, handleMenuClose] = useBoolean();
|
||||
|
||||
let itemRef: React.Ref<HTMLAnchorElement> =
|
||||
React.useRef<HTMLAnchorElement>(null);
|
||||
if (ref) {
|
||||
itemRef = ref;
|
||||
}
|
||||
|
||||
const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(
|
||||
itemRef,
|
||||
false
|
||||
);
|
||||
|
||||
useFocusEffect(focused, itemRef);
|
||||
|
||||
const {
|
||||
document,
|
||||
showParentDocuments,
|
||||
@@ -68,7 +82,7 @@ function DocumentListItem(
|
||||
|
||||
return (
|
||||
<DocumentLink
|
||||
ref={ref}
|
||||
ref={itemRef}
|
||||
dir={document.dir}
|
||||
role="menuitem"
|
||||
$isStarred={document.isStarred}
|
||||
@@ -80,6 +94,9 @@ function DocumentListItem(
|
||||
},
|
||||
}}
|
||||
{...rest}
|
||||
tabIndex={tabIndex}
|
||||
onKeyDown={handleKeyDown}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<Content>
|
||||
<Heading dir={document.dir}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useFocusEffect, useRovingTabIndex } from "react-roving-tabindex";
|
||||
import styled, { css } from "styled-components";
|
||||
import breakpoint from "styled-components-breakpoint";
|
||||
import { s, ellipsis } from "@shared/styles";
|
||||
@@ -33,9 +34,22 @@ function DocumentListItem(
|
||||
) {
|
||||
const { document, highlight, context, shareId, ...rest } = props;
|
||||
|
||||
let itemRef: React.Ref<HTMLAnchorElement> =
|
||||
React.useRef<HTMLAnchorElement>(null);
|
||||
if (ref) {
|
||||
itemRef = ref;
|
||||
}
|
||||
|
||||
const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(
|
||||
itemRef,
|
||||
false
|
||||
);
|
||||
|
||||
useFocusEffect(focused, itemRef);
|
||||
|
||||
return (
|
||||
<DocumentLink
|
||||
ref={ref}
|
||||
ref={itemRef}
|
||||
dir={document.dir}
|
||||
to={{
|
||||
pathname: shareId
|
||||
@@ -46,6 +60,14 @@ function DocumentListItem(
|
||||
},
|
||||
}}
|
||||
{...rest}
|
||||
tabIndex={tabIndex}
|
||||
onKeyDown={handleKeyDown}
|
||||
onClick={(ev) => {
|
||||
if (rest.onClick) {
|
||||
rest.onClick(ev);
|
||||
}
|
||||
handleClick();
|
||||
}}
|
||||
>
|
||||
<Content>
|
||||
<Heading dir={document.dir}>
|
||||
|
||||
Reference in new issue
Block a user