Handled Backspace at the beginning of the TODO element.#46
Open
Jayesh2812 wants to merge 3 commits intoupnotes-io:masterfrom
Open
Handled Backspace at the beginning of the TODO element.#46Jayesh2812 wants to merge 3 commits intoupnotes-io:masterfrom
Jayesh2812 wants to merge 3 commits intoupnotes-io:masterfrom
Conversation
bhujoshi
reviewed
Oct 26, 2022
| setItemText(items[itemIndex].name); | ||
| }, [changeFocus, focus, itemIndex, items]); | ||
|
|
||
| useEffect(() => { |
Contributor
There was a problem hiding this comment.
One useEffect above already doing the same. Can you remove it?
bhujoshi
reviewed
Oct 26, 2022
| }, [items[itemIndex].name]); | ||
|
|
||
| const handleDelete = () => { | ||
| items.splice(itemIndex, 1); |
Contributor
There was a problem hiding this comment.
Before changing the items array. Create a copy of items to avoid reference changes directly. You can do something like this.
const itemsCopy = [...items];
itemsCopy.splice(itemIndex, 1);
setItemsCallback([...itemsCopy]);
bhujoshi
reviewed
Oct 26, 2022
|
|
||
| if (inputRef.current!.selectionStart) return; // Do nothing if cursor isn't at start. | ||
|
|
||
| let previousItemElement = getNthTodoElement(itemIndex - 1); |
Contributor
There was a problem hiding this comment.
You can use the predefined setFocus function to focus the element. If you need a selection as well you can add one more method to setSelection. That you can do in different PR if needed.
bhujoshi
reviewed
Oct 26, 2022
|
|
||
| const handleArrowKey : KeyboardEventHandler<HTMLDivElement> = (e) => { | ||
| const inputs = document.querySelectorAll("input[type='text']"); | ||
| const inputsArray = Array.from(inputs); |
Contributor
There was a problem hiding this comment.
Again try to do the same using the setFocus method.
Author
|
I was out of town for few days, will start working on the changes this week. Thank you so much for the reviews and suggestions 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The user can now press
Backspaceat start of the TODO to do one of the following#37 issue will be fixed by merging this pull request.