Skip to content

feat: Add Screen Orientation API support to Page#24327

Open
Artur- wants to merge 9 commits into
mainfrom
feature/screen-orientation
Open

feat: Add Screen Orientation API support to Page#24327
Artur- wants to merge 9 commits into
mainfrom
feature/screen-orientation

Conversation

@Artur-

@Artur- Artur- commented May 12, 2026

Copy link
Copy Markdown
Member

Expose the browser Screen Orientation API through Page methods,
providing a read-only signal for tracking orientation changes and
methods to lock/unlock screen orientation for tablet and mobile apps.

Artur- added 2 commits May 8, 2026 15:13
Expose the browser Screen Orientation API through Page methods,
providing a read-only signal for tracking orientation changes and
methods to lock/unlock screen orientation for tablet and mobile apps.
Addresses three API gaps surfaced while building use cases against the
screen orientation API:

- Add ScreenOrientation.isLandscape() / isPortrait() so adaptive layouts
  do not have to spell out the two-value disjunction.
- Add ScreenOrientation.UNSUPPORTED, distinct from UNKNOWN: the client
  now reports "unsupported" from the bootstrap when screen.orientation
  is absent, so callers can tell "no data yet" from "the platform will
  never produce data."
- Replace lockOrientation's PendingJavaScriptResult return with the
  Geolocation.getPosition-style onSuccess/onError callbacks, plus a
  ScreenOrientationLockError record carrying the DOMException name and
  message. Rejected lock requests now surface reactively instead of
  vanishing unless the caller chained .then(...) themselves. A
  fire-and-forget single-arg overload logs failures at DEBUG.
@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown

Test Results

 1 442 files  + 2   1 442 suites  +2   1h 20m 44s ⏱️ -24s
10 147 tests +21  10 079 ✅ +21  68 💤 ±0  0 ❌ ±0 
10 619 runs  +21  10 550 ✅ +21  69 💤 ±0  0 ❌ ±0 

Results for commit f4ab918. ± Comparison against base commit 2cf1c20.

♻️ This comment has been updated with latest results.

…lback

Adds ExtendedClientDetails#isScreenOrientationSupported() for a synchronous
feature-detect (mirrors the Page screen-orientation signal) and a
Page#unlockOrientation(SerializableRunnable) overload that fires once the
unlock round-trip completes — symmetric with the lockOrientation callbacks.
*
* @return the read-only screen orientation signal
*/
public Signal<ScreenOrientationData> screenOrientationSignal() {

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.

Should it be getScreenOrientationSignal()
Also does the method name need the Signal at the end as the return type is Signal?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That is the "standard" in use in Flow

Artur- added 4 commits June 9, 2026 09:57
…ation

# Conflicts:
#	flow-client/src/main/frontend/Flow.ts
#	flow-server/src/main/java/com/vaadin/flow/component/page/ExtendedClientDetails.java
Align the screen orientation API with the WakeLock and Geolocation
siblings: surface lock failures as a typed ScreenOrientationLockErrorCode
(via ScreenOrientationLockError.errorCode()) so callers can switch on the
reason instead of comparing the raw DOMException name string.

Also funnel the DOM-event setScreenOrientation overload through the
bootstrap one to remove duplicated parse/log logic, matching the single
setter shape used by PageVisibility.
Move the screen orientation API off Page into a dedicated static facade
in com.vaadin.flow.component.screenorientation, matching the action-bearing
browser-API wrappers (Fullscreen, WakeLock, Geolocation) instead of the
read-only PageVisibility precedent it previously followed.

- ScreenOrientation: static facade (orientationSignal/lock/unlock), mirrors
  Fullscreen; per-UI state held in ScreenOrientationSupport via ComponentUtil
- Rename the ScreenOrientation enum to ScreenOrientationType (matches the
  W3C OrientationType and frees the ScreenOrientation name for the facade)
- New @NullMarked package-info for the package
- ExtendedClientDetails seeds via ScreenOrientation.setStateFromClient and
  reads isScreenOrientationSupported() through the facade signal
- Page no longer carries orientation signal/lock/unlock methods
Replace the ScreenOrientationSupport holder with the pattern WakeLock and
Geolocation already use (and that DESIGN_GUIDELINES prescribes): keep the
ValueSignal on UIInternals with a framework-only setter, and have the
ScreenOrientation facade read/write it and wire the DOM listener once via
an installed-flag guard. Removes the Fullscreen-style Support class, whose
facade did nothing but forward to it.
Artur- added 2 commits June 10, 2026 19:14
Address PR review feedback on the screen-orientation lock error API:

- The client now maps the DOMException name to a
  ScreenOrientationLockErrorCode constant before reporting the failure,
  so the raw browser error name never crosses the wire and Java code
  only sees terms meaningful to a Java developer. An unmapped exception
  keeps its name in the debug message so diagnostics are not lost.
- ScreenOrientationLockError is now (errorCode, debugInfo), following
  the GeolocationError naming convention where debugInfo is free-form
  browser wording meant for logging only. The name() accessor and the
  enum's domExceptionName()/fromName() plumbing are removed from the
  public API.
- The fire-and-forget unlock() delegates to unlock(callback) instead of
  duplicating the executeJs call.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: 🔎Iteration reviews

Development

Successfully merging this pull request may close these issues.

3 participants