twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.02k stars 1.48k forks source link

text input field focus should deactivate shortcuts #6051

Open mxcrbn opened 1 week ago

mxcrbn commented 1 week ago

Bug Description

typing specific characters (eg "g") in a text field triggers shortcuts

Example:

i was trying to add a stage in opportunities ("Contacting") but can't type the "g" + if I type eg "t" after typing "g", i'm redirected to that tasks screen

screen:
https://github.com/twentyhq/twenty/assets/53276986/b038280b-ac0a-42c1-a6fa-122f3cd6d203

Expected behavior

i can type my text without triggering shortcuts when focus is on text input field / can trigger shortcuts when no focus is on text input field

greptile-apps[bot] commented 1 week ago

To resolve the issue where typing in a text input field triggers shortcuts, follow these steps:

  1. Locate the TextInput component: This is likely where the focus handling should be adjusted.

  2. Modify the TextInput component to set the hotkey scope when the input field is focused. You can use the InputHotkeyScope enum to manage this.

  3. Example Code:

import { InputHotkeyScope } from 'path/to/InputHotkeyScope';

class TextInput extends React.Component {
  handleFocus = () => {
    // Set the hotkey scope to deactivate shortcuts
    InputHotkeyScope.setScope('textInput');
  };

  handleBlur = () => {
    // Revert the hotkey scope to its previous state
    InputHotkeyScope.revertScope();
  };

  render() {
    return (
      <input
        type="text"
        onFocus={this.handleFocus}
        onBlur={this.handleBlur}
        {...this.props}
      />
    );
  }
}
  1. Ensure InputHotkeyScope is properly implemented to manage the scope stack and deactivate shortcuts when the scope is set to textInput.

This should prevent shortcuts from being triggered when typing in a text input field.

Edit Issue Bot Settings