Skip to content

[core] Refactor getScrollbarSize to operate on window instead of document #43827

@Janpot

Description

@Janpot

Change the implementation of getScrollbarSize to avoid the need to use non-null assertion. See #43818 (comment)

export default function getScrollbarSize(win: Window = window): number {
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  const documentWidth = win.document.documentElement.clientWidth;
  return Math.abs(win.innerWidth - documentWidth);
}

Search keywords:

Metadata

Metadata

Assignees

Labels

internalBehind-the-scenes enhancement. Formerly called “core”.scope: modalChanges related to the modal.type: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions