Skip to content

feat(responsive): add useContainerWidth hook#1144

Open
JeanMarcMilletScality wants to merge 4 commits into
development/1.0from
improvement/responsive-use-container-width-hook
Open

feat(responsive): add useContainerWidth hook#1144
JeanMarcMilletScality wants to merge 4 commits into
development/1.0from
improvement/responsive-use-container-width-hook

Conversation

@JeanMarcMilletScality

@JeanMarcMilletScality JeanMarcMilletScality commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What

First of a progressive series merging the responsive-panels exploration into development/1.0. This PR adds only the foundational hookuseContainerWidth — plus its library export and unit tests. Nothing else from the exploration branch (AdaptivePanels, column-drop, icon-only buttons, fluid forms, navbar/sidebar/table changes) is included here.

Details

useContainerWidth is a container-width (not viewport) responsiveness primitive, for screens that must stay usable when a host side-panel shrinks the available space without changing the viewport width.

  • Callback-ref ResizeObserver; returns isNarrow / isNarrowerThan(px) for multi-tier layouts.
  • Optional hysteresis band to avoid flicker when the container rests on a breakpoint.
  • Ships NARROW_BREAKPOINT_PX (640) and TABLE_NARROW_BREAKPOINT_PX (820) constants, plus UseContainerWidthOptions / UseContainerWidthResult types.
  • Exported from src/lib/index.ts.

Compatibility

Purely additive / opt-in — no existing component behaviour changes.

Verification

  • tsc --noEmit clean
  • eslint clean on changed files
  • jest — 9 unit tests covering wide-first-before-measure, breakpoint flips in both directions, width rounding, custom breakpoint, the hysteresis band, and detaching the observed node

🤖 Generated with Claude Code

Container-width (not viewport) responsiveness primitive for narrow host
side-panels. Exposes isNarrow / isNarrowerThan(px) for multi-tier layouts
via a callback-ref ResizeObserver, with an optional hysteresis band to
prevent flicker on a breakpoint. Ships the NARROW_BREAKPOINT_PX and
TABLE_NARROW_BREAKPOINT_PX constants and is exported from the library
entry point. Opt-in; no existing behaviour changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bert-e

bert-e commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Hello jeanmarcmilletscality,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e

bert-e commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

Comment thread src/lib/components/responsive/useContainerWidth.ts
JeanMarcMilletScality and others added 2 commits June 25, 2026 14:49
Stubs a controllable ResizeObserver to verify the hook reports wide-first
before measuring, flips on the breakpoint in both directions, rounds the
measured width, honours a custom breakpoint and the hysteresis band, and
stops observing a detached node.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rename the test cases to state the exact return value being asserted
(isNarrow / isNarrowerThan / width) and to flag the ones relying on the
default breakpoint. Their widths are derived from NARROW_BREAKPOINT_PX so
the relationship to the default is explicit. No behaviour change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bert-e

bert-e commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

Comment thread src/lib/components/responsive/useContainerWidth.ts Outdated
@JeanMarcMilletScality JeanMarcMilletScality force-pushed the improvement/responsive-use-container-width-hook branch from 0e09fca to 218e4d8 Compare June 25, 2026 13:36
useContainerWidth should report the element's own width — matching its
CSS width and the breakpoint constants — rather than a value that shifts
with the container's padding. Read borderBoxSize in the observer, and
where it is unsupported re-measure the target's border box (instead of
contentRect's content box) so every path agrees with the
getBoundingClientRect sync read and isNarrow never flips after mount.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JeanMarcMilletScality JeanMarcMilletScality force-pushed the improvement/responsive-use-container-width-hook branch from 218e4d8 to c736d3f Compare June 25, 2026 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

Development

Successfully merging this pull request may close these issues.

2 participants