Skip to content

fix(html5): prevent pinch-to-zoom for viewers and WB users on touch devices - #24947

Merged
antobinary merged 2 commits into
bigbluebutton:v3.0.x-developfrom
Tainan404:i-24900
Apr 24, 2026
Merged

antobinary merged 2 commits into
bigbluebutton:v3.0.x-developfrom
Tainan404:i-24900

Conversation

@Tainan404

Copy link
Copy Markdown
Member

What does this PR do?

On phones and tablets, participants could accidentally zoom the presentation by pinching the screen, which should only be allowed for the presenter. We now block pinch gestures for all non-presenter participants, keeping the presentation locked in place on touch devices. As a bonus, any accidental drawing stroke triggered while pinching is automatically cancelled for whiteboard users.

Closes Issue(s)

Closes #24900

How to test

  • Create a Meeting
  • Join a Meeting as Mod
  • Join a Meerting as viewer on mobile
  • as viewer try to pinch screen
  • as Mod enable multi user whiteboard
  • as viewer try again and test multi user wb
  • mod makes viewer preseter
  • viewer test wb as preseter

More

ScreenRecording_04-21-2026.13-59-17_1.MP4

@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 91f26ff1-ca65-49f2-81b0-d8006bc947ce

📥 Commits

Reviewing files that changed from the base of the PR and between e3222c5 and 367d0a0.

📒 Files selected for processing (2)
  • bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx
  • bigbluebutton-html5/imports/ui/components/whiteboard/hooks.js

Walkthrough

Added three coordinated protections to prevent pinch-zoom for non-presenter users: an HTML-level gesturechange listener that calls preventDefault(), a conditional absolute overlay in the Whiteboard React component that blocks touch interaction for viewers without whiteboard access, and updated event handlers/hooks to intercept non-primary pointer events and multi-touch touchstart (preventing default and stopping propagation) while ensuring consistent listener removal with { capture: true }.

Sequence Diagram

sequenceDiagram
    participant User as User/Touch Device
    participant Document as HTML Document
    participant Hooks as useMouseEvents Hooks
    participant Component as Whiteboard Component
    participant Editor as tlEditorRef (Editor)

    User->>Document: gesturestart / gesturechange (pinch)
    Document->>Document: gesturestart -> preventDefault()
    Document->>Document: gesturechange -> preventDefault()

    User->>Hooks: pointerdown (non-primary)
    Hooks->>Hooks: isPresenter?
    alt Not Presenter & non-primary
        Hooks->>Hooks: stopPropagation()
        Hooks->>Editor: cancel current action
    else Presenter or primary pointer
        Hooks->>Editor: allow action
    end

    User->>Component: touchstart (2+ fingers)
    Component->>Component: isPresenter?
    alt Non-Presenter & multi-touch
        Component->>Component: preventDefault() + stopPropagation()
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: preventing pinch-to-zoom for non-presenter participants on touch devices.
Description check ✅ Passed The description explains what the PR does, which issue it closes, and provides detailed testing steps that align with the code changes.
Linked Issues check ✅ Passed The PR successfully addresses issue #24900 by blocking pinch gestures for non-presenter participants and canceling accidental whiteboard strokes, matching the expected behavior.
Out of Scope Changes check ✅ Passed All changes focus on preventing pinch-to-zoom and touch interactions for non-presenters, which is directly aligned with the issue requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx (1)

2346-2355: Overlay is purely decorative — mark it as such for assistive tech and consider pointer-events.

The overlay is rendered only to capture/swallow touch gestures for non-presenter, non-WB-access users. Minor hardening suggestions:

  • Add aria-hidden="true" so screen readers don't announce an empty region.
  • touchAction: 'none' only affects touch gestures; if the intent is to fully block interaction (including mouse), consider pointerEvents: 'auto' explicitly, or conversely pointerEvents: 'none' if you want the overlay to be purely a touch-action hint without capturing clicks. Today, with default pointerEvents: auto and zIndex: 300, the overlay will swallow mouse clicks aimed at the tldraw canvas for viewers without WB access — verify that's intentional (viewers can't click anything in tldraw anyway, but this also covers any tldraw-rendered overlays like cursors).
Proposed tweak
       {!isPresenter && !hasWBAccess && (
         <div
+          aria-hidden="true"
           style={{
             position: 'absolute',
             inset: 0,
             zIndex: 300,
             touchAction: 'none',
           }}
         />
       )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx` around
lines 2346 - 2355, The overlay rendered in the conditional (!isPresenter &&
!hasWBAccess) should be marked decorative and have explicit pointer handling:
add aria-hidden="true" to the div and set pointerEvents: 'auto' in the inline
style object (or pointerEvents: 'none' if you instead want it to be purely
non-interactive while still preserving touchAction behavior); update the JSX for
the overlay div (the element rendered when !isPresenter && !hasWBAccess) to
include these attributes so assistive tech ignores it and pointer behavior is
explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bigbluebutton-html5/imports/ui/components/whiteboard/hooks.js`:
- Around line 263-268: The handler handlePointerDown should only call
tlEditorRef.current.cancel() for non-primary touch pointers so stylus/pen
strokes aren't aborted; update the conditional to include event.pointerType ===
'touch' (e.g., if (!event.isPrimary && event.pointerType === 'touch' &&
!isPresenterRef.current) { event.stopPropagation();
tlEditorRef.current?.cancel(); }) while keeping the stopPropagation and
references to handlePointerDown, isPresenterRef, and tlEditorRef unchanged.

---

Nitpick comments:
In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx`:
- Around line 2346-2355: The overlay rendered in the conditional (!isPresenter
&& !hasWBAccess) should be marked decorative and have explicit pointer handling:
add aria-hidden="true" to the div and set pointerEvents: 'auto' in the inline
style object (or pointerEvents: 'none' if you instead want it to be purely
non-interactive while still preserving touchAction behavior); update the JSX for
the overlay div (the element rendered when !isPresenter && !hasWBAccess) to
include these attributes so assistive tech ignores it and pointer behavior is
explicit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 99114256-24b8-404f-999a-4127347e01f6

📥 Commits

Reviewing files that changed from the base of the PR and between c84ba36 and e3222c5.

📒 Files selected for processing (3)
  • bigbluebutton-html5/client/main.html
  • bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx
  • bigbluebutton-html5/imports/ui/components/whiteboard/hooks.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents unintended pinch-to-zoom behavior on touch devices for non-presenters in the HTML5 client’s presentation/whiteboard area, and cancels accidental whiteboard strokes triggered during multi-touch gestures.

Changes:

  • Block multi-touch pinch gestures for non-presenters via touch/pointer event handling in whiteboard hooks.
  • Add a transparent overlay to disable touch gestures when the user has neither presenter nor whiteboard access.
  • Prevent default handling of gesturechange events globally (in addition to existing gesturestart) to further reduce iOS Safari zoom behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
bigbluebutton-html5/imports/ui/components/whiteboard/hooks.js Adds pointer/touch gesture handling to suppress pinch actions for non-presenters and cancel accidental strokes.
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx Adds an overlay layer with touch-action: none for users without presenter/WB access to block touch gestures.
bigbluebutton-html5/client/main.html Adds gesturechange prevention to complement existing gesturestart prevention.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@antobinary antobinary added this to the Release 3.0 milestone Apr 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@ramonlsouza ramonlsouza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tested on a real mobile device, works as expected!

@antobinary
antobinary merged commit afdea5a into bigbluebutton:v3.0.x-develop Apr 24, 2026
33 checks passed
antobinary added a commit that referenced this pull request Oct 20, 2026
A presenter's two-finger pinch moved the camera twice per frame:
tldraw's own pinch (use-gesture on the canvas, absolute zoom on every
pointermove) and BBB's touchmove handler (throttled to 175 ms, steps of
10 zoom points animated over 175 ms). Each tldraw write cancelled BBB's
animation, which is the flicker (18-36 zoom reversals per slow pinch),
and the camera ended on tldraw's value. Touch zoom was only published
when that value, rounded, equalled the toolbar zoom BBB had computed
from an earlier camera, so a slow pinch was never published and viewers
kept the old view. tldraw also let the zoom go below 100 %.

No second touch pointer reaches tldraw any more (stopped at capture, as
the viewer block of #24947 already did), so its pinch never starts.
BBB's handler is the only writer: a continuous zoom from the finger
distance, clamped to 100-400 % (25-400 % on the infinite whiteboard)
like the wheel, about the point between the fingers, which it also
follows for a two-finger pan. While the gesture flag is set, every
camera change is published like a wheel zoom, zoomChanger follows the
camera, and the zoom effect does not re-animate the camera to the
rounded percent; the flag lasts 300 ms past touchend, longer than
zoomChanger's 200 ms debounce.

The second finger ends what the first one started only when a tool is
busy: interrupt() drops an undragged dot, complete() keeps a dragged
stroke. Idle tools are left alone, because tldraw's idle states switch
to the select tool on cancel, which took the pencil away from a
whiteboard user on a two-finger tap. A shape removed before it was
persisted is now dropped from the pending batch; otherwise the dropped
dot was still sent and came back from the server.

The pan clamp in onBeforeChange took the viewport of the camera before
the write. At 100 % that viewport is the whole slide, so the first zoom
step of a pinch, wheel or keyboard zoom was pushed back to (0, 0) and
the zoom stopped being centred on the fingers. It now uses the zoom
being written. The range gate of #25671 takes 100 % from initialZoomRef,
the base the handler, the wheel and the toolbar percent use, so writes
at the bounds pass. It only checks user writes, so a resize or page
restore is not rejected while that base catches up.

Fixes #26079
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.0] prevent zoom by viewers on touch panel

4 participants