Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup abbreviations using the keyboard #2731

Closed
KonstantinEpam23 opened this issue Jun 1, 2023 · 3 comments · Fixed by #2744
Closed

Lookup abbreviations using the keyboard #2731

KonstantinEpam23 opened this issue Jun 1, 2023 · 3 comments · Fixed by #2744

Comments

@KonstantinEpam23
Copy link
Collaborator

KonstantinEpam23 commented Jun 1, 2023

Background
From the main canvas, provide a way for the user to quickly lookup abbreviations (templates, functional groups, etc.) via typing their names.

Solution
When a user is in the main editor view and starts typing the name of the abbreviation on the keyboard - a context window should appear containing current user input and a list of matching abbreviations in a form of a drop-down list that can be navigated via the keyboard.
When a user presses the "Enter" key - the context window closes and the selected abbreviation is set as the current template that the user can place on the canvas.
There may be collisions of abbreviation names and current Ketcher keyboard shortcuts, so the context menu should only appear if more than one letter was typed within a certain time limit (e.g. appear if the user typed the second letter within 1000 ms)

  • The suggestions list should contain abbreviations with names - DCM (dichloromethane)
  • If an abbreviation is empty or the same as the name only the name should be displayed - CO2Me
  • The list of abbreviations should contain all Elements from the Periodic Table. Labels should be in the form Element (Name), F.e. Br (Bromine).
  • If there're no search results for entered string, then display a dropdown with the text No matching results.
  • If a user removes all entered text, then display a dropdown with the text Start typing atom or template structure name without any options.
  • Only one highlighted substring should be displayed for the option label. Priority order should be followed:
    • there's no abbreviation, highlight substring in a name
    • the lookup string is located at the beginning of an abbreviation, highlight the substring in an abbreviation
    • the lookup string is located at the beginning of a name, highlight the substring in a name
    • if the lookup string is located at the beginning of an abbreviation and a name at the same time or not located at the beginning of both of them, check the similarity for an abbreviation and name
    • similarity for an abbreviation is greater or equal to the similarity of a name, highlight the substring in an abbreviation
    • otherwise, highlight the substring in a name

The suggestions list should be sorted according to these criteria:

  1. Matched substring is at the beginning of the name or abbreviation. F.e. "Hg (Mercury)". If 2 items are equal by this criteria, then check criteria 2
  2. Highest similarity of lookup value with name or abbreviation. Where similarity is the result of the division of the length of the matched string by the length of the name or abbreviation. F.e. for the lookup value mer and option Hg (Mercury) similarity will be 3/7 by matching with the element name. For the lookup value hg and option Hg (Mercury) will be 1 by matching the element abbreviation. If the lookup value is found in the name and the abbreviation, then the highest value of similarity should be taken for this option. If 2 items are equal by this criteria, then check criteria 3
  3. Lexicographical comparison in case point 1 and 2 give the same result. The whole option label should be used for lexicographical comparison - Hg (Mercury)

#184100484

@PetrKurkin
Copy link
Collaborator

PetrKurkin commented Jun 1, 2023

General behavior and look
Search

If there is not enough space for a dropdown, it should appear above the search
search position

@KonstantinEpam23 KonstantinEpam23 assigned gairon and unassigned Nitvex Jun 1, 2023
gairon added a commit that referenced this issue Jun 6, 2023
* Add possibility to search abbreviations without opening the Templates dialog
gairon added a commit that referenced this issue Jun 6, 2023
* Add possibility to search abbreviations without opening the Templates dialog
@gairon gairon linked a pull request Jun 6, 2023 that will close this issue
@gairon
Copy link
Contributor

gairon commented Jun 7, 2023

Found duplicated abbreviations (numbers are count of instances):

  • Indole - 2
  • alpha-D-Allopyranose - 2
  • alpha-D-Altropyranose - 2
  • alpha-D-Galactopyranose - 2
  • alpha-D-Glucopyranose - 2
  • alpha-D-Gulopyranose - 2
  • alpha-D-Idopyranose - 2
  • alpha-D-Mannopyranose - 2
  • alpha-D-Talopyranose - 2
  • Bicyclo[4-1-1]octane - 2
  • Bicyclo[4-2-1]nonane - 3
  • Bicyclo[4-2-2]decane - 3
  • Bicyclo[4-3-1]decane - 4
  • Bicyclo[4-3-2]undecane - 4
  • Bicyclo[4-4-1]undecane - 3
  • Bicyclo[4-4-2]dodecane - 3
  • GLY-Glycine - 2
  • Cyclopentadiene - 2
  • Ring5 - 2

An example from the Templates dialog:
image

gairon added a commit that referenced this issue Jun 7, 2023
* Add possibility to search abbreviations without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
…iations-using-the-keyboard

# Conflicts:
#	packages/ketcher-react/src/script/ui/state/hotkeys.ts
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 13, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 15, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
@gairon
Copy link
Contributor

gairon commented Jun 15, 2023

Screen.Recording.2023-06-15.at.11.52.18-1.mov

gairon added a commit that referenced this issue Jun 15, 2023
…iations-using-the-keyboard

# Conflicts:
#	packages/ketcher-react/src/script/ui/state/hotkeys.ts
gairon added a commit that referenced this issue Jun 15, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 15, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 19, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 19, 2023
…iations-using-the-keyboard

# Conflicts:
#	packages/ketcher-react/jest.config.js
#	packages/ketcher-react/src/script/ui/views/components/Dialog/Dialog.tsx
gairon added a commit that referenced this issue Jun 19, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 19, 2023
gairon added a commit that referenced this issue Jun 20, 2023
gairon added a commit that referenced this issue Jun 20, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 20, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 20, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 20, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
gairon added a commit that referenced this issue Jun 20, 2023
gairon added a commit that referenced this issue Jun 21, 2023
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
Nitvex pushed a commit that referenced this issue Jun 22, 2023
* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog

* #2731 - Lookup abbreviations using the keyboard
* Add possibility to search abbreviations from Templates, Functional Groups, Salt and Solvents and Elements without opening the Templates dialog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants