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(Search): fix an error when showNoResults=false and arrow down is pressed #3938

Conversation

ysugimoto
Copy link
Contributor

@ysugimoto ysugimoto commented Apr 27, 2020

This PR fixes an unexpected error on Search module.

When the Search module built with showNoResults={false} props, the <div class="result"> element won't present in DOM. And if a user types cursor-down (keycode: 40) in search input, then it raises an error:

Search.js:260 Uncaught TypeError: Cannot read property 'querySelector' of null
    at Search.eval [as scrollSelectedItemIntoView] (Search.js:260)
    at Search.eval [as moveSelectionBy] (Search.js:252)
    at Array.eval (Search.js:113)
    at EventSet.dispatchEvent (event-stack.development.js:164)
    at EventPool.dispatchEvent (event-stack.development.js:275)
    at eval (event-stack.development.js:341)
    at Map.forEach (<anonymous>)
    at HTMLDocument.eval (event-stack.development.js:340)

This PR can avoid that error by checking menu element existence.

@welcome
Copy link

welcome bot commented Apr 27, 2020

💖 Thanks for opening this pull request! 💖

Here is a list of things that will help get it across the finish line:

  • Run yarn lint locally to catch formatting errors. This will fix some errors automatically, commit and push any changes.
  • Run yarn test locally to catch errors. This ensures all components still behave as they should.
  • Run yarn start to run the doc site locally and try a few pages, ensuring everything is in good working order.
  • Include tests when adding/changing behavior.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2020

Codecov Report

Merging #3938 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3938      +/-   ##
==========================================
- Coverage   99.84%   99.84%   -0.01%     
==========================================
  Files         184      178       -6     
  Lines        3218     3152      -66     
==========================================
- Hits         3213     3147      -66     
  Misses          5        5              
Impacted Files Coverage Δ
src/modules/Search/Search.js 99.55% <100.00%> (-0.01%) ⬇️
src/elements/Button/Button.js 95.45% <0.00%> (-0.11%) ⬇️
src/modules/Popup/Popup.js 98.71% <0.00%> (-0.04%) ⬇️
src/modules/Tab/Tab.js 100.00% <0.00%> (ø)
src/views/Card/Card.js 100.00% <0.00%> (ø)
src/elements/Flag/Flag.js 100.00% <0.00%> (ø)
src/elements/Icon/Icon.js 100.00% <0.00%> (ø)
src/elements/List/List.js 100.00% <0.00%> (ø)
src/elements/Step/Step.js 100.00% <0.00%> (ø)
... and 44 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f64679...9731192. Read the comment docs.

@vercel vercel bot temporarily deployed to Preview July 28, 2020 12:16 Inactive
@layershifter layershifter changed the title Fixed: Search module error on down-cursor key if showNoResults=false fix(Search): fix an error when showNoResults=false and arrow down is pressed Jul 28, 2020
Copy link
Member

@layershifter layershifter left a comment

Choose a reason for hiding this comment

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

Verified, the issue is fixed 👍

@layershifter layershifter merged commit cf945cc into Semantic-Org:master Jul 28, 2020
@welcome
Copy link

welcome bot commented Jul 28, 2020

Congrats on merging your first pull request! 🎉🎉🎉

robot victory dance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants