From cce4ddd64ec9bdc8f763d8d4a479a158777caafe Mon Sep 17 00:00:00 2001 From: Echo Date: Thu, 3 Sep 2026 14:45:25 +0000 Subject: [PATCH] Hotkeys, Storybook theme fix, allow bullets (#40375) --- .storybook/preview.tsx | 2 +- .../mastodon/components/card/index.tsx | 1 - .../mastodon/components/hotkeys/index.tsx | 54 ++++++++++++------- .../features/compose/redesign/quote.tsx | 1 - eslint.config.mjs | 10 ---- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 5e8b4852cb1..abf318d7ead 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -170,7 +170,7 @@ const preview: Preview = { (Story, { globals }) => { const theme = globals.theme; useEffect(() => { - document.body.setAttribute('data-color-scheme', theme); + document.documentElement.dataset.colorScheme = theme; }, [theme]); return ; }, diff --git a/app/javascript/mastodon/components/card/index.tsx b/app/javascript/mastodon/components/card/index.tsx index ddb87a449d7..dfe79a012ef 100644 --- a/app/javascript/mastodon/components/card/index.tsx +++ b/app/javascript/mastodon/components/card/index.tsx @@ -94,7 +94,6 @@ export const CardTitle: React.FC< {children} {afterContent && ( - // eslint-disable-next-line no-restricted-syntax -- Allow •  •  {afterContent} diff --git a/app/javascript/mastodon/components/hotkeys/index.tsx b/app/javascript/mastodon/components/hotkeys/index.tsx index e8390b72557..6c97ad8c30c 100644 --- a/app/javascript/mastodon/components/hotkeys/index.tsx +++ b/app/javascript/mastodon/components/hotkeys/index.tsx @@ -1,5 +1,7 @@ import { useEffect, useRef } from 'react'; +import type { PolymorphicProps } from '@/types/polymorphic'; + import { normalizeKey, isKeyboardEvent, matchesKeyCode } from './utils'; /** @@ -271,6 +273,24 @@ export function useHotkeys(handlers: HandlerMap) { return ref; } +interface HotkeysProps { + /** + * An object containing functions to be run when a hotkey is pressed. + * The key must be the name of a registered hotkey, e.g. "help" or "search" + */ + handlers: HandlerMap; + /** + * When enabled, hotkeys will be matched against the document root + * rather than only inside of this component's DOM node. + */ + global?: boolean; + /** + * Allow the rendered `div` to be focused + */ + focusable?: boolean; + children: React.ReactNode; +} + /** * The Hotkeys component allows us to globally register keyboard combinations * under a name and assign actions to them, either globally or scoped to a portion @@ -290,28 +310,24 @@ export function useHotkeys(handlers: HandlerMap) { * * Now this function will be called when the 'open' hotkey is pressed by the user. */ -export const Hotkeys: React.FC<{ - /** - * An object containing functions to be run when a hotkey is pressed. - * The key must be the name of a registered hotkey, e.g. "help" or "search" - */ - handlers: HandlerMap; - /** - * When enabled, hotkeys will be matched against the document root - * rather than only inside of this component's DOM node. - */ - global?: boolean; - /** - * Allow the rendered `div` to be focused - */ - focusable?: boolean; - children: React.ReactNode; -}> = ({ handlers, global, focusable = true, children }) => { +export const Hotkeys = ({ + as: asComp, + handlers, + global, + focusable = true, + children, + ...props +}: PolymorphicProps) => { const ref = useHotkeys(handlers); + const Comp = asComp ?? 'div'; return ( -
+ {children} -
+ ); }; diff --git a/app/javascript/mastodon/features/compose/redesign/quote.tsx b/app/javascript/mastodon/features/compose/redesign/quote.tsx index 63583e8e6c1..4f1ba383793 100644 --- a/app/javascript/mastodon/features/compose/redesign/quote.tsx +++ b/app/javascript/mastodon/features/compose/redesign/quote.tsx @@ -184,7 +184,6 @@ const ComposeQuoteBody: React.FC<{ defaultMessage='Poll {sep} {isOpen, select, open {Accepting responses} other {Closed}}' values={{ isOpen: poll.expired ? 'closed' : 'open', - // eslint-disable-next-line no-restricted-syntax sep: <>•, }} /> diff --git a/eslint.config.mjs b/eslint.config.mjs index d7cbaaf907b..85257e8b0ee 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -164,16 +164,6 @@ export default tseslint.config([ }, rules: { - 'no-restricted-syntax': [ - 'error', - { - // eslint-disable-next-line no-restricted-syntax - selector: 'Literal[value=/•/], JSXText[value=/•/]', - // eslint-disable-next-line no-restricted-syntax - message: "Use '·' (middle dot) instead of '•' (bullet)", - }, - ], - 'formatjs/enforce-description': 'off', // description values not currently used 'formatjs/enforce-id': 'off', // Explicit IDs are used in the project 'formatjs/enforce-placeholders': 'off', // Issues in short_number.jsx