-
Notifications
You must be signed in to change notification settings - Fork 4k
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(Dropdown): fix minCharacter
prop behaviour
#1722
Conversation
<Container> | ||
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa strong. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede link mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.</p> | ||
</Container> | ||
const DropdownExampleSearchSelection = () => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, this looks like the wrong content for this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, looks like I missed the big fat WIP
😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I will revert this before merge 😄
e2bbd17
to
3124e5c
Compare
Codecov Report
@@ Coverage Diff @@
## master #1722 +/- ##
==========================================
- Coverage 99.75% 99.75% -0.01%
==========================================
Files 142 142
Lines 2468 2464 -4
==========================================
- Hits 2462 2458 -4
Misses 6 6
Continue to review full report at Codecov.
|
3124e5c
to
a3f6639
Compare
minCharacter
propminCharacter
prop behaviour
a3f6639
to
42c14ce
Compare
@levithomason I done everything except placeholder's behaviour. Let me know what you think about proposed changes in this PR, gifs were captured from SUI, you can compare them with our current docs. If it will okay, I'll add tests and prepare PR for merge. |
noResultsMessage: 'No results found.', | ||
openOnFocus: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only prop sort there.
debug('mouse is not down, opening') | ||
if (openOnFocus) this.open() | ||
if (openOnFocus && openable) this.open() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defines behaviour with focus
.
if (keyboardKey.getCode(e) !== keyboardKey.Enter) return | ||
e.preventDefault() | ||
|
||
if (search && _.isEmpty(this.getMenuOptions())) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disables Enter
key when nothing find.
// Do not access document when server side rendering | ||
if (!isBrowser) return | ||
document.addEventListener('mouseup', this.handleDocumentMouseUp) | ||
if (isBrowser) document.addEventListener('mouseup', this.handleDocumentMouseUp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor refactor.
this.isMouseDown = false | ||
// Do not access document when server side rendering | ||
if (!isBrowser) return | ||
document.removeEventListener('mouseup', this.handleDocumentMouseUp) | ||
if (isBrowser) document.removeEventListener('mouseup', this.handleDocumentMouseUp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor refactor.
|
||
if (!search) return this.toggle(e) | ||
if (open) return | ||
if (searchQuery.length >= minCharacters || minCharacters === 1) this.open(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update behaviour with click on search input.
…React into fix/dropdown-minchars
.simulate('change', { target: { value: faker.hacker.noun().substring(0, 1) } }) | ||
|
||
dropdownMenuIsClosed() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test was moved to another section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@levithomason We're ready for review there, will be awesome to hear your thoughts.
Would be great to see this merged. It fixes a considerable bug in |
ec28a3a
to
fb14678
Compare
fb14678
to
5f70d73
Compare
|
||
this.close(e) | ||
} | ||
toggle = e => this.state.open ? this.close(e) : this.open(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method was updated because its logic was moved to handleClick
@timworx thanks for the feedback, I missed this problem, hovewer it's fixed. Just a note, @levithomason I think you should ship this in |
@levithomason please take an attention to this PR. |
The next shipment (here in a few minutes) will be breaking because of #1730 which has already been merged. We won't update previous versions until we hit a stable 1.0 release. Bugs and features will be shipped as fast as possible without going backwards. I'll demo this and see about shipping it now in |
Released in |
Fixes #1718.
Behaviours
This PR fixes issues with
minCharacters
and also some other inconsistent things.TODO
Enter
)onClick
Note, that if you click on input after it was openned, you will not close it, e.g. click don't toggle searchable dropdown.
minCharacters
= 1minCharacters
= 3Dropdown wasn't openned after click.
onFocus
minCharacters
= 1Note, focus doesn't affect placeholder. After focus was lost first item was selected, because item was focused.
minCharacters
= 1minCharacters
= 3Dropdown wasn't openned after click.
onChange
Note, is you have no results message and you click
Enter
key, nothing will be happened.minCharacters
= 1minCharacters
= 3