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

Fix MarkdownEditor suggestions filtering bug and allow lazy-loading suggestions #2424

Merged
merged 9 commits into from
Oct 12, 2022

Conversation

iansan5653
Copy link
Contributor

  1. Fixs a bug where suggestions values shorter than the filter query would always appear first in the list, even if they don't match the query. This fixes MarkdownEditor suggestions break when querying by 3 or more characters #2423
  2. Adds support for lazy-loading suggestions data so it doesn't have to be ready when the editor is mounted. This was done by changing the prop types to optionally accept an async function instead of a plain old array. This way, the consumer can wait to make an API request until the MarkdownEditor asks for the data. Then they can cache the data for future rendering. The new prop types look like emojiSuggestions?: Emoji[] | (() => Promise<Emoji[]>). This resolves MarkdownEditor should allow lazy-loading suggestions #2422
  3. [minor] Improves the MarkdownEditor test suite to perform the mocking of offsetHeight on the HTMLElement prototype in a beforeAll instead of on the element instances themselves in a layoutEffect. This is far less buggy and removes any chance of race conditions (which I was encountering when moving to async event handlers for rendering suggestions).

@iansan5653 iansan5653 self-assigned this Oct 11, 2022
@iansan5653 iansan5653 requested review from a team and siddharthkp October 11, 2022 17:21
@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2022

🦋 Changeset detected

Latest commit: d832344

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 11, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 77.65 KB (0%)
dist/browser.umd.js 78.31 KB (0%)

@iansan5653 iansan5653 temporarily deployed to github-pages October 11, 2022 17:27 Inactive
@iansan5653 iansan5653 temporarily deployed to github-pages October 11, 2022 17:36 Inactive
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

🥳

@iansan5653 iansan5653 enabled auto-merge (squash) October 11, 2022 20:55
@iansan5653 iansan5653 temporarily deployed to github-pages October 11, 2022 21:01 Inactive
Copy link
Contributor

@Lukeghenco Lukeghenco left a comment

Choose a reason for hiding this comment

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

The lazy loading of emojis, references and suggestions is killer.

The bug fixes here are stuff we've logged in the pull requests app we are building too. This should resolve our same issues.

Thanks for leading the charge here.

@siddharthkp siddharthkp temporarily deployed to github-pages October 12, 2022 12:11 Inactive
Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

Scoped to drafts, ship it

@iansan5653 iansan5653 merged commit 09728c9 into main Oct 12, 2022
@iansan5653 iansan5653 deleted the markdown-suggestions-fixes branch October 12, 2022 12:16
@primer-css primer-css mentioned this pull request Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants