Misc fixes from qa pass (#5650)

This commit is contained in:
Tom Moor
2023-08-04 23:40:36 -04:00
committed by GitHub
parent 80acc16791
commit 042ea7b61f
11 changed files with 96 additions and 54 deletions

View File

@@ -2,8 +2,8 @@ import {
CaretDownIcon,
CaretUpIcon,
CaseSensitiveIcon,
MoreIcon,
RegexIcon,
ReplaceIcon,
} from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
@@ -35,6 +35,7 @@ export default function FindAndReplace({ readOnly }: Props) {
);
const selectionRef = React.useRef<string | undefined>();
const inputRef = React.useRef<HTMLInputElement>(null);
const inputReplaceRef = React.useRef<HTMLInputElement>(null);
const { t } = useTranslation();
const theme = useTheme();
const [showReplace, setShowReplace] = React.useState(false);
@@ -102,10 +103,10 @@ export default function FindAndReplace({ readOnly }: Props) {
);
// Callbacks
const handleMore = React.useCallback(
() => setShowReplace((state) => !state),
[]
);
const handleMore = React.useCallback(() => {
setShowReplace((state) => !state);
setTimeout(() => inputReplaceRef.current?.focus(), 100);
}, []);
const handleCaseSensitive = React.useCallback(() => {
setCaseSensitive((state) => {
@@ -306,12 +307,12 @@ export default function FindAndReplace({ readOnly }: Props) {
{navigation}
{!readOnly && (
<Tooltip
tooltip={t("More options")}
tooltip={t("Replace options")}
delay={500}
placement="bottom"
>
<ButtonLarge onClick={handleMore}>
<MoreIcon color={theme.textSecondary} />
<ReplaceIcon color={theme.textSecondary} />
</ButtonLarge>
</Tooltip>
)}
@@ -322,6 +323,7 @@ export default function FindAndReplace({ readOnly }: Props) {
<StyledInput
maxLength={255}
value={replaceTerm}
ref={inputReplaceRef}
placeholder={t("Replacement")}
onKeyDown={handleReplaceKeyDown}
onRequestSubmit={handleReplaceAll}

View File

@@ -105,7 +105,10 @@ function ToolbarMenu(props: Props) {
{item.children ? (
<ToolbarDropdown item={item} />
) : (
<ToolbarButton onClick={handleClick(item)} active={isActive}>
<ToolbarButton
onClick={handleClick(item)}
active={isActive && !item.label}
>
{item.label && <Label>{item.label}</Label>}
{item.icon}
</ToolbarButton>

View File

@@ -12,13 +12,6 @@ export default function dividerMenuItems(
const { schema } = state;
return [
{
name: "hr",
tooltip: dictionary.pageBreak,
attrs: { markup: "***" },
active: isNodeActive(schema.nodes.hr, { markup: "***" }),
icon: <PageBreakIcon />,
},
{
name: "hr",
tooltip: dictionary.hr,
@@ -26,5 +19,12 @@ export default function dividerMenuItems(
active: isNodeActive(schema.nodes.hr, { markup: "---" }),
icon: <HorizontalRuleIcon />,
},
{
name: "hr",
tooltip: dictionary.pageBreak,
attrs: { markup: "***" },
active: isNodeActive(schema.nodes.hr, { markup: "***" }),
icon: <PageBreakIcon />,
},
];
}