mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(app): allow the inbox shortcut while the composer is empty (#1714)
This commit is contained in:
1 parent
9ea750152e
commit
5ce5669f17
4 files changed
+8
-30
No files matched your search
@@ -16,9 +16,8 @@ import {
|
||||
EDIT_MESSAGE_DESCRIPTOR,
|
||||
EMOJIS_DESCRIPTOR,
|
||||
} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
import Keybind from '@app/features/input/state/InputKeybind';
|
||||
import {LexicalRichInput, type LexicalRichInputHandle} from '@app/features/lexical/composer/LexicalRichInput';
|
||||
import {doesEventMatchShortcut, useMarkdownKeybinds} from '@app/features/messaging/hooks/useMarkdownKeybinds';
|
||||
import {useMarkdownKeybinds} from '@app/features/messaging/hooks/useMarkdownKeybinds';
|
||||
import type {Message} from '@app/features/messaging/models/MessagingMessage';
|
||||
import MessageEdit from '@app/features/messaging/state/MessageEdit';
|
||||
import {applyMarkdownSegments} from '@app/features/messaging/utils/MarkdownToSegmentUtils';
|
||||
@@ -155,16 +154,6 @@ export const EditingMessageInput = observer(
|
||||
if (event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
const composer = composerRef.current;
|
||||
const selection = composer == null ? null : composer.getSelection();
|
||||
const hasSelectionRange = selection != null && selection.start !== selection.end;
|
||||
const inboxCombo = Keybind.getByAction('chat_toggle_inbox').combo;
|
||||
if (doesEventMatchShortcut(event, inboxCombo) && !hasSelectionRange && actualContent.trim().length === 0) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
ComponentDispatch.dispatch('INBOX_OPEN');
|
||||
return;
|
||||
}
|
||||
if (event.key === 'Escape' && !event.shiftKey && !event.defaultPrevented && !event.nativeEvent.isComposing) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
@@ -52,8 +52,7 @@ import type {FlatEmoji} from '@app/features/emoji/types/EmojiTypes';
|
||||
import {ExpressionPickerSheet} from '@app/features/expressions/components/modals/ExpressionPickerSheet';
|
||||
import GuildGuilds from '@app/features/guild/state/Guilds';
|
||||
import {CANCEL_DESCRIPTOR, CONTINUE_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
import Keybind from '@app/features/input/state/InputKeybind';
|
||||
import type {ComposerHandle, ComposerSelectionRange} from '@app/features/lexical/composer/ComposerHandle';
|
||||
import type {ComposerHandle} from '@app/features/lexical/composer/ComposerHandle';
|
||||
import {insertComposerEmoji} from '@app/features/lexical/composer/ComposerInsertion';
|
||||
import {LexicalComposerInput} from '@app/features/lexical/composer/LexicalComposerInput';
|
||||
import {
|
||||
@@ -69,7 +68,7 @@ import {showAttachmentPermissionDeniedModal} from '@app/features/messaging/compo
|
||||
import {FileSizeTooLargeModal} from '@app/features/messaging/components/alerts/FileSizeTooLargeModal';
|
||||
import {TooManyAttachmentsModal} from '@app/features/messaging/components/alerts/TooManyAttachmentsModal';
|
||||
import {useTextareaAttachments} from '@app/features/messaging/hooks/useCloudUpload';
|
||||
import {doesEventMatchShortcut, useMarkdownKeybinds} from '@app/features/messaging/hooks/useMarkdownKeybinds';
|
||||
import {useMarkdownKeybinds} from '@app/features/messaging/hooks/useMarkdownKeybinds';
|
||||
import {type SendMessageFunction, useMessageSubmission} from '@app/features/messaging/hooks/useMessageSubmission';
|
||||
import {useTextareaDraftAndTyping} from '@app/features/messaging/hooks/useTextareaDraftAndTyping';
|
||||
import {useTextareaEditing} from '@app/features/messaging/hooks/useTextareaEditing';
|
||||
@@ -848,22 +847,9 @@ export const LexicalChannelTextareaContent = observer(
|
||||
}, [channel.guildId]);
|
||||
const handleEditorKeyDown = useCallback(
|
||||
(event: React.KeyboardEvent<HTMLElement>) => {
|
||||
const handle = handleRef.current;
|
||||
let selection: ComposerSelectionRange | null = null;
|
||||
if (handle !== null) {
|
||||
selection = handle.getSelection();
|
||||
}
|
||||
const hasSelectionRange = selection ? selection.start !== selection.end : false;
|
||||
const inboxCombo = Keybind.getByAction('chat_toggle_inbox').combo;
|
||||
if (doesEventMatchShortcut(event, inboxCombo) && !hasSelectionRange && value.trim().length === 0) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
ComponentDispatch.dispatch('INBOX_OPEN');
|
||||
return;
|
||||
}
|
||||
handleEscapeKey(event);
|
||||
},
|
||||
[handleEscapeKey, value],
|
||||
[handleEscapeKey],
|
||||
);
|
||||
const handleSubmit = useCallback(() => {
|
||||
if (!canSubmit) {
|
||||
|
||||
@@ -662,6 +662,8 @@ const getDefaultKeybinds = (
|
||||
action: 'chat_toggle_inbox',
|
||||
label: i18n._(TOGGLE_THE_INBOX_DESCRIPTOR),
|
||||
combo: {key: 'i', ctrlOrMeta: true},
|
||||
ignoreWhileTyping: true,
|
||||
editableFocusBehavior: 'allow_when_empty',
|
||||
section: 'chat',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -108,7 +108,8 @@ export const doesEventMatchShortcut = (event: ShortcutKeyEvent, target: Partial<
|
||||
};
|
||||
const shouldPreserveConflictingAction = (action: KeybindCommand, options: MarkdownKeybindScopeOptions): boolean => {
|
||||
if (!options.preserveEditableFocusActions) return false;
|
||||
return Keybind.getDefaultByAction(action)?.editableFocusBehavior === 'allow';
|
||||
const behavior = Keybind.getDefaultByAction(action)?.editableFocusBehavior;
|
||||
return behavior === 'allow' || behavior === 'allow_when_empty';
|
||||
};
|
||||
const getConflictingKeybindActions = (options: MarkdownKeybindScopeOptions = {}): Set<KeybindCommand> => {
|
||||
const actions = new Set<KeybindCommand>();
|
||||
|
||||
Reference in new issue
Block a user