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

SelectionList bugs #1731

Merged
merged 4 commits into from
Oct 3, 2019
Merged

SelectionList bugs #1731

merged 4 commits into from
Oct 3, 2019

Conversation

benjamincharity
Copy link
Contributor

@benjamincharity benjamincharity commented Oct 2, 2019

@benjamincharity benjamincharity requested a review from a team as a code owner October 2, 2019 12:51
@benjamincharity benjamincharity self-assigned this Oct 2, 2019
@codecov
Copy link

codecov bot commented Oct 2, 2019

Codecov Report

Merging #1731 into release will decrease coverage by 0.04%.
The diff coverage is 90%.

Impacted file tree graph

@@             Coverage Diff             @@
##           release    #1731      +/-   ##
===========================================
- Coverage    98.82%   98.77%   -0.05%     
===========================================
  Files          134      134              
  Lines         5711     5729      +18     
  Branches       976      982       +6     
===========================================
+ Hits          5644     5659      +15     
- Misses          67       69       +2     
- Partials         0        1       +1
Impacted Files Coverage Δ
...ction-list-panel/selection-list-panel.component.ts 97.61% <80%> (-2.39%) ⬇️
...ion-list-panel/selection-list-trigger.directive.ts 94.24% <93.33%> (-0.59%) ⬇️
terminus-ui/select/src/select.component.ts 96.07% <0%> (ø) ⬆️

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 1565f8a...fe14755. Read the comment docs.

Copy link
Contributor

@atlwendy atlwendy left a comment

Choose a reason for hiding this comment

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

how could the coverage go down? 😱

@@ -73,6 +72,9 @@ export const TS_SELECTION_LIST_SCROLL_STRATEGY_FACTORY_PROVIDER = {
useFactory: TS_SELECTION_LIST_SCROLL_STRATEGY_FACTORY,
};

// The max height of the select's overlay panel
export const SELECTION_LIST_PANEL_MAX_HEIGHT = 256;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it the max height regardless current window/screen size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, just like select and autocomplete.

// Try to use the 2nd option in case the first option is blank or a filter etc. Fall back to the first item if needed.
const options = this.selectionListPanel.options.toArray();
const option = options[1] || options[0];
return option.elementRef.nativeElement.offsetHeight;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the option height be defined by consumers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It pretty much already is. We are checking the rendered height, so if the consumer puts in 200px tall content, that's what it will be. Our default height is just created by our CSS. So the template drives the height.

@@ -752,7 +770,8 @@ export class TsSelectionListTriggerDirective<ValueType = string> implements Cont
// Create a new stream of panelClosingActions, replacing any previous streams that were created, and flatten it so our stream only
// emits closing events...
switchMap(() => {
this.resetActiveItem();
// Focus the first option when options change
this.selectionListPanel.keyManager.setActiveItem(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does resetActiveItem also do the same thing - set the first option active? although, this way is clearer...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resetActiveItem clears the selection completely. Which mentally seems fine until you start using the component. The UX of being able to just type to filter and hit enter is just better imo

@@ -965,4 +965,24 @@ describe(`TsSelectionListComponent`, function() {
expect(fixture.componentInstance.clicked).toHaveBeenCalled();
}));

// Note: Simply dispatching the arrow down key on the trigger repeatedly did not wor
Copy link
Contributor

Choose a reason for hiding this comment

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

your keyboard might have cut k out...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

tick(1000);
fixture.detectChanges();

expect(instance.panel.keyManager.activeItemIndex).toEqual(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

This however doesn't test using arrow key that option list should scroll when list is longer than viewport height - do notice that arrow key doesn't work.... we do have other specs that using arrow down key, right? wonder how they're different..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wouldn't expect it to? This test is called should focus first option when the options collection changes and that is all it tests. There is a TODO test above this to cover that called should update panel scroll position when focusing an out-of-view option

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I didn't see a todo and that's all the specs you added so just wanted to point it out...

@benjamincharity
Copy link
Contributor Author

how could the coverage go down?

Cause we are unfortunately under the gun currently to get some items out, so I'm leaving several test.todos in the code which we will need to circle back on.

@benjamincharity benjamincharity merged commit cd18162 into release Oct 3, 2019
@benjamincharity benjamincharity deleted the 1730-selectionlist-hover branch October 3, 2019 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants