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

[PM-17094] - Vault and Collection filters pop in after Vault content causing content to shift #13165

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jaasen-livefront
Copy link
Collaborator

@jaasen-livefront jaasen-livefront commented Jan 30, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-17094

📔 Objective

Given the vault list filter component is relying on async data it's loading after the main content and causing it to shift. This PR adds a shareReplay function to share the filters across all the observers to ensure they all render together.

📸 Screenshots

Screen.Recording.2025-01-30.at.11.31.59.AM.mov

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@jaasen-livefront jaasen-livefront requested a review from a team as a code owner January 30, 2025 19:32
@jaasen-livefront jaasen-livefront changed the title [PM-17094] - add loading state service for vault list filters and apply to vault [PM-17094] - Vault and Collection filters pop in after Vault content causing content to shift Jan 30, 2025
Copy link
Contributor

github-actions bot commented Jan 30, 2025

Logo
Checkmarx One – Scan Summary & Details76905cf2-93d8-45d2-9758-cfad2af72efe

New Issues (4)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
HIGH CVE-2025-0995 Npm-electron-34.0.0 Vulnerable Package
HIGH CVE-2025-0996 Npm-electron-34.0.0 Vulnerable Package
HIGH CVE-2025-0997 Npm-electron-34.0.0 Vulnerable Package
HIGH CVE-2025-0998 Npm-electron-34.0.0 Vulnerable Package

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 35.31%. Comparing base (7984bb3) to head (ac78867).

Files with missing lines Patch % Lines
...lt/popup/components/vault-v2/vault-v2.component.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #13165       +/-   ##
===========================================
+ Coverage   15.76%   35.31%   +19.54%     
===========================================
  Files          27     3128     +3101     
  Lines        1884    92603    +90719     
  Branches        0    16826    +16826     
===========================================
+ Hits          297    32702    +32405     
- Misses       1587    57441    +55854     
- Partials        0     2460     +2460     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -92,13 +93,16 @@ export class VaultV2Component implements OnInit, AfterViewInit, OnDestroy {

private allFilters$ = this.vaultPopupListFiltersService.allFilters$;

protected listFiltersLoaded$ = this.vaultListFilterLoadingStateService.filtersLoaded$;
Copy link
Member

Choose a reason for hiding this comment

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

❓ Do we need a separate service? I would suspect we can just hook into the existing this.allFilters$ above and use it in the *ngIf in the template.

Maybe there is something else I'm missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@shane-melton That was my first try but it appears the issue seems to lie in the vault list filters component and the fact that it renders after the main content. The only way to ensure the main content loads with it is to wait for allFilters$ to emit in the filter component. I removed the call to delay(0) and requestAnimationFrame as that isn't required. I'm happy to pair up or chat if you want to go over it in more detail.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My mind is on the same path as @shane-melton, I believe the solution is correct but the service to manage the "loaded" state isn't needed, right?

listFiltersLoaded$ could use the allFilters$ directly:

protected listFiltersLoaded$ = this.allFilters$.pipe(
  take(1),
  takeUntilDestroyed(this.destroyRef),
);

Copy link
Member

Choose a reason for hiding this comment

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

I did a bit more digging into to this yesterday and I believe I found the cause of the problem you were having @jaasen-livefront.

The vault popup filter service does not use a shareReplay() for its organizations$, folders$, and collections$ observables. So, those values are recomputed for every subscriber, which includes the vault filter section component, which is rendered after the main content as you mention, and so it has a slight delay for the second computation of those observables.

When I added the shareReplay() to those 3 base observables in the filter service AND update the loading$ observable in the vault-v2 component to also check if allFilters$ has emitted the vault loads all at once instead of popping in piece by piece.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@shane-melton Wow, so much simpler. Thank you!

Copy link
Collaborator

Choose a reason for hiding this comment

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

AND update the loading$ observable in the vault-v2 component to also check if allFilters$ has emitted the vault loads all at once instead of popping in piece by piece.

@jaasen-livefront I believe this piece still needs to be implemented from @shane-melton's feedback otherwise this is looking good!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

private vaultListFilterLoadingStateService: VaultListFilterLoadingStateService,
) {}

private destroy$ = new Subject<void>();
Copy link
Member

Choose a reason for hiding this comment

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

⚠️ We never call destory$.next() so the takeUntil operator below never triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants