laboratoriobridge / bold

https://bold.bridge.ufsc.br
MIT License
75 stars 9 forks source link

[ SelectSingle ] Fix props override bug #810

Closed mathbalduino closed 1 year ago

mathbalduino commented 1 year ago

Hey,

I was trying to build a custom <SelectAsync /> using the onClear and onIconClick props, but I noticed some strange behavior: When I passed any of them, to <SelectAsync />, the component misbehaved

Looking into the code, to see what happened, I noticed the following lines of code: /src/components/Select/SelectSingle/SelectSingle.tsx:110 image

If you look closely, you'll see that the lines 112 and 113 are composing both onIconClick and onClear props, directly from the props object, without destructing them from it. At line 115, we can see that we are overriding everything with what we have on the rest object, that still contains both onIconClick and onClear.

So, if you set them, the lines 112 and 113 will be ignored. This PR will just extract both props from the props object, so that the rest object doesn't override them

codecov[bot] commented 1 year ago

Codecov Report

Merging #810 (2a51745) into main (8dde349) will not change coverage. The diff coverage is n/a.

:exclamation: Current head 2a51745 differs from pull request most recent head 0e75b8b. Consider uploading reports for the commit 0e75b8b to get more accurate results

@@           Coverage Diff           @@
##             main     #810   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files         525      525           
  Lines        4450     4450           
  Branches      686      686           
=======================================
  Hits         4393     4393           
  Misses         57       57           
Files Changed Coverage Δ
...rc/components/Select/SelectSingle/SelectSingle.tsx 100.00% <ø> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more