-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Pickers: Fix suggestions not having proper value selected #4408
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
Merged
joschect
merged 14 commits into
microsoft:master
from
joschect:joschect/fix-pickers-suggestions
Mar 30, 2018
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
09873d8
Revert "FocusTrapZone does not correctly trap focus when last child i…
joschect ac6a5e5
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
joschect 4567e59
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
joschect 351a18d
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
joschect 2a629fb
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
joschect ff19db2
fix picker suggestions and add many tests
joschect 7f4494a
adding snap file
joschect 2e423b6
adding change file
joschect af252a4
improve test
joschect 25316a5
fix tests and config
joschect 8d5e717
revert test changes
joschect 82dca88
last test update
joschect 2928672
update test name and snapshot
joschect 81ae8a5
remove tests to expedite checkin
joschect File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
common/changes/office-ui-fabric-react/joschect-fix-pickers-suggestions_2018-03-29-23-30.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "Pickers: fix bug where suggestions wouldn't have correct value selected", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "[email protected]" | ||
| } |
91 changes: 91 additions & 0 deletions
91
packages/office-ui-fabric-react/src/components/pickers/Suggestions/Suggestions.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
|
|
||
| /* tslint:disable:no-unused-variable */ | ||
| import * as React from 'react'; | ||
| import * as ReactDOM from 'react-dom'; | ||
| import * as ReactTestUtils from 'react-dom/test-utils'; | ||
| /* tslint:enable:no-unused-variable */ | ||
| import * as renderer from 'react-test-renderer'; | ||
|
|
||
| import { Suggestions } from './Suggestions'; | ||
| import { ISuggestionItemProps } from './Suggestions.types'; | ||
| import { ISuggestionModel } from './SuggestionsController'; | ||
|
|
||
| const suggestions = [ | ||
| 'black', | ||
| 'blue', | ||
| 'brown', | ||
| 'cyan', | ||
| 'green', | ||
| 'magenta', | ||
| 'mauve', | ||
| 'orange', | ||
| 'pink', | ||
| 'purple', | ||
| 'red', | ||
| 'rose', | ||
| 'violet', | ||
| 'white', | ||
| 'yellow']; | ||
|
|
||
| function generateSimpleSuggestions(selectedIndex: number = 0) { | ||
| return suggestions.map<ISuggestionModel<ISimple>>((value, index) => { | ||
| return { | ||
| item: { | ||
| key: value, | ||
| name: value | ||
| }, | ||
| selected: index === 0 | ||
|
||
| }; | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| const basicSuggestionRenderer = (props: ISimple) => { | ||
| return <div> { props.name } </div>; | ||
| }; | ||
|
|
||
| export interface ISimple { | ||
| key: string; | ||
| name: string; | ||
| } | ||
|
|
||
| function mockOnClick() { | ||
| console.log('clicked'); | ||
| } | ||
|
|
||
| describe('Suggestions', () => { | ||
|
|
||
| it('renders a list properly', () => { | ||
|
|
||
| const component = renderer.create( | ||
| <Suggestions | ||
| onRenderSuggestion={ basicSuggestionRenderer } | ||
| onSuggestionClick={ mockOnClick } | ||
| suggestions={ generateSimpleSuggestions() } | ||
| /> | ||
| ); | ||
| const tree = component.toJSON(); | ||
| expect(tree).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('scrolls to selected index properly', () => { | ||
| const component = renderer.create( | ||
| <Suggestions | ||
| onRenderSuggestion={ basicSuggestionRenderer } | ||
| onSuggestionClick={ mockOnClick } | ||
| suggestions={ generateSimpleSuggestions() } | ||
| /> | ||
| ); | ||
|
|
||
| component.update( | ||
| <Suggestions | ||
| onRenderSuggestion={ basicSuggestionRenderer } | ||
| onSuggestionClick={ mockOnClick } | ||
| suggestions={ generateSimpleSuggestions(8) } | ||
| /> | ||
| ); | ||
| const tree = component.toJSON(); | ||
| expect(tree).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit: maybe name the snapshot
'suggestion: "a"'so it's more clear what you're testing hereNormally we add
hover()afterclick(). I forget the exact reasoning. Might be fine without it since you callsetValue(), but when Screener finishes running, I'd check to make sure the snapshot looks as intendedThere 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.
I'll rename it. The screenshot does look correct!