kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Merge branch 'hotkeys-statuses' into 'develop'
Move GlobalHotkeys back to features/ui for now See merge request soapbox-pub/soapbox!2593environments/review-develop-3zknud/deployments/3581
commit
72de8fb90f
|
@ -29,7 +29,6 @@ import {
|
||||||
OnboardingWizard,
|
OnboardingWizard,
|
||||||
WaitlistPage,
|
WaitlistPage,
|
||||||
} from 'soapbox/features/ui/util/async-components';
|
} from 'soapbox/features/ui/util/async-components';
|
||||||
import GlobalHotkeys from 'soapbox/features/ui/util/global-hotkeys';
|
|
||||||
import { createGlobals } from 'soapbox/globals';
|
import { createGlobals } from 'soapbox/globals';
|
||||||
import {
|
import {
|
||||||
useAppSelector,
|
useAppSelector,
|
||||||
|
@ -176,7 +175,6 @@ const SoapboxMount = () => {
|
||||||
<BrowserRouter basename={BuildConfig.FE_SUBDIRECTORY}>
|
<BrowserRouter basename={BuildConfig.FE_SUBDIRECTORY}>
|
||||||
<CompatRouter>
|
<CompatRouter>
|
||||||
<ScrollContext shouldUpdateScroll={shouldUpdateScroll}>
|
<ScrollContext shouldUpdateScroll={shouldUpdateScroll}>
|
||||||
<GlobalHotkeys>
|
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route
|
<Route
|
||||||
path='/embed/:statusId'
|
path='/embed/:statusId'
|
||||||
|
@ -202,7 +200,6 @@ const SoapboxMount = () => {
|
||||||
</div>
|
</div>
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
</GlobalHotkeys>
|
|
||||||
</ScrollContext>
|
</ScrollContext>
|
||||||
</CompatRouter>
|
</CompatRouter>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
|
|
|
@ -135,6 +135,7 @@ import {
|
||||||
EditGroup,
|
EditGroup,
|
||||||
FollowedTags,
|
FollowedTags,
|
||||||
} from './util/async-components';
|
} from './util/async-components';
|
||||||
|
import GlobalHotkeys from './util/global-hotkeys';
|
||||||
import { WrappedRoute } from './util/react-router-helpers';
|
import { WrappedRoute } from './util/react-router-helpers';
|
||||||
|
|
||||||
// Dummy import, to make sure that <Status /> ends up in the application bundle.
|
// Dummy import, to make sure that <Status /> ends up in the application bundle.
|
||||||
|
@ -511,6 +512,7 @@ const UI: React.FC<IUI> = ({ children }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<GlobalHotkeys node={node}>
|
||||||
<div ref={node} style={style}>
|
<div ref={node} style={style}>
|
||||||
<div
|
<div
|
||||||
className={clsx('pointer-events-none fixed z-[90] h-screen w-screen transition', {
|
className={clsx('pointer-events-none fixed z-[90] h-screen w-screen transition', {
|
||||||
|
@ -565,6 +567,7 @@ const UI: React.FC<IUI> = ({ children }) => {
|
||||||
</BundleContainer>
|
</BundleContainer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</GlobalHotkeys>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,10 @@ const keyMap = {
|
||||||
|
|
||||||
interface IGlobalHotkeys {
|
interface IGlobalHotkeys {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
|
node: React.MutableRefObject<HTMLDivElement | null>
|
||||||
}
|
}
|
||||||
|
|
||||||
const GlobalHotkeys: React.FC<IGlobalHotkeys> = ({ children }) => {
|
const GlobalHotkeys: React.FC<IGlobalHotkeys> = ({ children, node }) => {
|
||||||
const hotkeys = useRef<HTMLDivElement | null>(null);
|
const hotkeys = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
@ -48,9 +49,9 @@ const GlobalHotkeys: React.FC<IGlobalHotkeys> = ({ children }) => {
|
||||||
|
|
||||||
const handleHotkeyNew = (e?: KeyboardEvent) => {
|
const handleHotkeyNew = (e?: KeyboardEvent) => {
|
||||||
e?.preventDefault();
|
e?.preventDefault();
|
||||||
if (!hotkeys.current) return;
|
if (!node.current) return;
|
||||||
|
|
||||||
const element = hotkeys.current.querySelector('textarea#compose-textarea') as HTMLTextAreaElement;
|
const element = node.current.querySelector('textarea#compose-textarea') as HTMLTextAreaElement;
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
element.focus();
|
element.focus();
|
||||||
|
@ -59,9 +60,9 @@ const GlobalHotkeys: React.FC<IGlobalHotkeys> = ({ children }) => {
|
||||||
|
|
||||||
const handleHotkeySearch = (e?: KeyboardEvent) => {
|
const handleHotkeySearch = (e?: KeyboardEvent) => {
|
||||||
e?.preventDefault();
|
e?.preventDefault();
|
||||||
if (!hotkeys.current) return;
|
if (!node.current) return;
|
||||||
|
|
||||||
const element = hotkeys.current.querySelector('input#search') as HTMLInputElement;
|
const element = node.current.querySelector('input#search') as HTMLInputElement;
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
element.focus();
|
element.focus();
|
||||||
|
|
Ładowanie…
Reference in New Issue