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

Notes list: Fix console error when there are no matching notes #1776

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

codebykat
Copy link
Member

Fix

If you search for a string that matches no notes, this error appears in the console: Failed DOMException: "No key or key range specified.". This was introduced in #1648 and is due to the fake notes being added to the notes list as placeholders. In this PR we properly guard against the selected note ID being null.

This was happening in two ways:

  1. If no notes nor tag matches were returned, we'd get null for the selected note ID, and onSelectNote wasn't checking for that. Now it does.
  2. If tag matches are returned but no notes, we'd try to set the selected note ID to the fake placeholder note, which didn't have an ID. Instead we want to select the first actual note, which requires moving the code that determines which note should be selected before the code that adds the placeholders to the notes list.

Test

  1. Open the app and development console
  2. Search for a string that has no matches in either tags or notes
  3. Verify that no errors appear in the console log
  4. Search for a string that matches tags but no notes text
  5. Verify that no errors appear
  6. Select different notes and make sure they correctly stay selected

Release

These changes do not require release notes.

@codebykat codebykat self-assigned this Dec 12, 2019
@codebykat codebykat requested a review from a team December 12, 2019 08:48
Copy link
Contributor

@belcherj belcherj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested well and code looks good.

@codebykat codebykat merged commit 86f0d3a into develop Dec 13, 2019
@codebykat codebykat deleted the fix/notes-bucket-console-errors branch December 13, 2019 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants