Skip to content

Sheets: add selection stats (sum, average, count) to sheets bottom bar#493

Open
the-narwhal wants to merge 4639 commits into
ProtonMail:mainfrom
the-narwhal:main
Open

Sheets: add selection stats (sum, average, count) to sheets bottom bar#493
the-narwhal wants to merge 4639 commits into
ProtonMail:mainfrom
the-narwhal:main

Conversation

@the-narwhal

Copy link
Copy Markdown
Contributor

What

Adds a selection statistics display to the Proton Sheets bottom bar, the sum, average, and count that appear in the bottom-right corner when you highlight multiple cells, matching the behaviour of Google Sheets, Excel, and LibreOffice Calc.

Why

This feature existed in the legacy UI via the SheetStatus component from @rowsncolumns/spreadsheet, but was never ported when the new UI was built. There was no comment or TODO indicating it was deliberately dropped, it appears to have simply been missed.

How

  • Added a SelectionStats memo component to BottomBar.tsx. It reads activeSheetId, selections, merges, and getEffectiveValue from useUI((ui) => ui.legacy.*) and renders the stats on the right side of the bar.
  • The useMemo dependencies include getEffectiveValue, which comes from spreadsheetState and gets a new reference after formula recalculation, so stats stay up to date without any extra wiring.
  • Extracted all computation into a standalone selectionStats.ts module (no external dependencies) for clean testability.
  • Gave SheetTabs a flex-1 min-w-0 class so it properly fills the available space and the stats are naturally pinned to the right.

Behaviour

  • Single cell selected → nothing shown
  • Multiple cells with numbers → Sum: X Average: Y Count: Z
  • Mixed numbers and text → Sum and Average reflect only numeric cells; Count reflects all non-empty cells
  • All-empty selection → nothing shown
  • Merged cells → only the owner (top-left) cell is counted, never double-counted
  • Very large selections → processing is capped at 50,000 cells to bound CPU cost
  • Read-only and revision modes → stats are still shown (they're informational only)

Testing

27 unit tests in selectionStats.test.ts covering all of the above cases including edge cases for Infinity, NaN, false, 0, floating-point accumulation artifacts, multi-range aggregation, merge deduplication, the cell cap, and locale-aware number formatting.

MargeBot and others added 30 commits April 21, 2026 09:15
Prevent concurrent referral spotlight feature PUTs

See merge request web/clients!24282
VPNPLG-58: Add payload and telemetry when forking the session

See merge request web/clients!24135
fix: fix icon alignment in cancellation flow

See merge request web/clients!24315
Add offer card UI components

See merge request web/clients!24302
added temporary need content and config

See merge request web/clients!24307
feat: workspace premium cancelation flow

See merge request web/clients!24319
Add news subscription for Meet

See merge request web/clients!24209
use the same setting menu for extension as for web

See merge request web/clients!24241
INWEB-867: Add common setup for Slack API in the CI

See merge request web/clients!24271
Add new permissions modals and stop requesting permissions automatically

See merge request web/clients!24248
DRVWEB: Search blobs encryption/decryption

See merge request web/clients!23888
[IDTEAM-5613] Add telemetry for sharing

See merge request web/clients!24221
Limit sharing settings visibility only to admins on parent share

See merge request web/clients!24326
[DRVWEB-4974] Album listing sdk

See merge request web/clients!23946
Enable telemetry for Meet

See merge request web/clients!24331
Vijayasingam and others added 16 commits April 24, 2026 12:58
Fix a bug storing feature flags in cookie

See merge request web/clients!24454
[DRVWEB-4967] delete legacy drive view

See merge request web/clients!24263
NOISSUE: Adapt telemetry for tv flow

See merge request web/clients!24405
Defer update prompt if user is in meeting

See merge request web/clients!24450
Mail BYOE: hide lock icons in sent messages when `X-Pm-Byoe` header is present

See merge request web/clients!24000
PostQuantumOptInModal: prompt for auth before committing the opt-in

See merge request web/clients!24457
Add LoginLink member creation mode

See merge request web/clients!24448
Show sum, average, and count in the bottom bar when multiple cells are
selected, matching the behaviour of Google Sheets, Excel, and LibreOffice.

This existed in the legacy UI via SheetStatus from @rowsncolumns/spreadsheet
but was not ported to the new UI.
@the-narwhal the-narwhal marked this pull request as ready for review April 26, 2026 15:48
@mmso mmso force-pushed the main branch 9 times, most recently from 3a2ffcb to 8b49cee Compare June 9, 2026 09:23
@mmso mmso force-pushed the main branch 4 times, most recently from 25168a8 to 97c88ca Compare June 12, 2026 09:51
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.