-
Notifications
You must be signed in to change notification settings - Fork 3
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
DON-1092 – fix campaign card grid input focus breaking Safari scroll positions #1780
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
29afbd0
DON-1092 – fix campaign card grid input focus breaking Safari scroll …
NoelLH d45c3f3
Update src/app/explore/explore.component.ts
NoelLH 3e1303b
Update src/app/explore/explore.component.ts
NoelLH 7ec20f2
Name `scrollPositionY` in other places we use it too
NoelLH 848618c
DON-1092 – Explain `blurredSinceLastMajorScroll` resets
NoelLH 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import {DatePipe, isPlatformBrowser} from '@angular/common'; | ||
import {Component, HostListener, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core'; | ||
import {DatePipe, isPlatformBrowser, ViewportScroller} from '@angular/common'; | ||
import {Component, HostListener, Inject, OnDestroy, OnInit, PLATFORM_ID, ViewChild} from '@angular/core'; | ||
import {ActivatedRoute, Router} from '@angular/router'; | ||
import { BiggiveCampaignCardFilterGrid } from '@biggive/components-angular'; | ||
import {skip, Subscription} from 'rxjs'; | ||
|
||
import {currencyPipeDigitsInfo} from '../../environments/common'; | ||
|
@@ -19,15 +20,19 @@ import {HighlightCard} from "../highlight-cards/HighlightCard"; | |
providers: [DatePipe] | ||
}) | ||
export class ExploreComponent implements OnDestroy, OnInit { | ||
@ViewChild(BiggiveCampaignCardFilterGrid) cardGrid: BiggiveCampaignCardFilterGrid; | ||
|
||
campaigns: CampaignSummary[]; | ||
currencyPipeDigitsInfo = currencyPipeDigitsInfo; | ||
loading = false; // Server render gets initial result set; set true when filters change. | ||
/** Whether any non-default search logic besides an order change has been applied. */ | ||
searched = false; | ||
|
||
private blurredSinceLastMajorScroll = false; | ||
private offset = 0; | ||
private routeParamSubscription: Subscription; | ||
private searchServiceSubscription: Subscription; | ||
private readonly smallestSignificantScrollPx = 250; | ||
|
||
beneficiaryOptions: string[] = []; | ||
categoryOptions: string[] = []; | ||
|
@@ -47,6 +52,7 @@ export class ExploreComponent implements OnDestroy, OnInit { | |
private route: ActivatedRoute, | ||
private router: Router, | ||
private pageMeta: PageMetaService, | ||
private scroller: ViewportScroller, | ||
public searchService: SearchService, | ||
@Inject(PLATFORM_ID) private platformId: Object, | ||
) {} | ||
|
@@ -124,6 +130,18 @@ export class ExploreComponent implements OnDestroy, OnInit { | |
} | ||
|
||
onScroll() { | ||
const scrollPositionY = this.scroller.getScrollPosition()[1]; | ||
if (scrollPositionY < this.smallestSignificantScrollPx) { | ||
// If we're now near the top, reset any previous input blurring as it might be helpful to blur again. | ||
this.blurredSinceLastMajorScroll = false; | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This early return may stop some |
||
|
||
if (!this.blurredSinceLastMajorScroll) { | ||
this.cardGrid && this.cardGrid.unfocusInputs(); | ||
this.blurredSinceLastMajorScroll = true; | ||
} | ||
|
||
if (this.moreMightExist()) { | ||
this.more(); | ||
} | ||
|
This file contains 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.
I don't think I'm following the logic here. This has a small scroll position so I guess is a minor scroll? So why does it affect the state of
blurredSinceLastMajorScroll
?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.
@bdsl The idea is that if you go back to the top, you are more likely to be about to interact with the search fields. So there's a reasonable chance that it will be useful to blur afresh when you're done. I'll add a comment.
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.
848618c