Skip to content

feat(env-switcher): persist hash and carry text selection into DA editor - #891

Draft
rofe wants to merge 6 commits into
mainfrom
issue-889
Draft

rofe wants to merge 6 commits into
mainfrom
issue-889

Conversation

@rofe

@rofe rofe commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fix #889

What

  • Rendered environments (preview, live, dev, review, prod): persist the URL
    hash/anchor (#...) to the target environment URL.
  • DA editor: when switching to the editor and the content source is
    Document Authoring, carry the user's current text selection into the editor
    as a ?select= query param so DA can restore/scroll to it.
    • Only added when a non-empty selection exists and the source is DA; other
      editors (SharePoint, Google Docs, BYOM) are unaffected.
    • The param is left in the URL after processing so selections are shareable.

Notes

  • The selection is captured continuously via a selectionchange listener,
    because interacting with the sidekick (e.g. the env switcher) collapses the
    live document selection. The cache is cleared when the selection collapses
    with focus outside the sidekick (i.e. the user deselects on the page).
  • DA-side consumption (reading ?select= and applying it to the editor) is a
    separate follow-up on adobe/da-live.

🤖 Generated with Claude Code

Persist the URL hash/anchor across environment switches (incl. edit).
The text fragment directive (:~:text=...) is stripped from the page's
window.location by the browser, so it is read from the tab URL via a new
getTabUrl internal action. For DA edit URLs the directive is appended to
the existing route anchor; other pre-existing anchors are ignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rofe rofe changed the title feat(env-switcher): persist hash when switching environments feat(env-switcher): persist hash and text fragment when switching environments Aug 6, 2026
@rofe
rofe requested a review from dylandepass August 6, 2026 13:23
Replace the text-fragment (:~:text=) approach with a selection-based one.
The browser strips fragment directives from window.location and DA content
lives in shadow DOM / loads async, so native text fragments cannot be
applied there.

Instead, track the last non-empty text selection (via a selectionchange
listener) as a text-fragment-style descriptor ([prefix-,]exact[,-suffix])
and append it to DA edit URLs as ?select=, so DA can locate and restore the
selection. Rendered environments (preview/live/dev/review/prod) persist the
plain hash/anchor only.

Reverts the getTabUrl internal action introduced earlier.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The stubbed Selection object failed a TS check (insufficient type overlap).
Drive updateSelection with a real range/selection instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rofe rofe changed the title feat(env-switcher): persist hash and text fragment when switching environments feat(env-switcher): persist hash and carry text selection into DA editor Aug 8, 2026
rofe and others added 3 commits August 8, 2026 17:51
Add a documented selection field, and clear the cache when the selection
collapses with focus outside the sidekick, so users can discard a pending
selection before switching to the editor. Collapses caused by interacting
with the sidekick (which move focus into it) keep the cache.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Store the selection as { exact, prefix, suffix } and emit it as
?select=/?selectPrefix=/?selectSuffix= via searchParams.set. This lets DA
consume each value with a plain searchParams.get() (proper decoding, no
custom descriptor parser), prioritizing ease of consumption over a compact
URL, while keeping prefix/suffix disambiguation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Defer prefix/suffix disambiguation until users report ambiguity. Store the
selection as plain text and emit a single ?select= param, which DA can read
with searchParams.get(). Simpler on both sides.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rofe

rofe commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

DA-side consumer follow-up (reading ?select= and applying it in the editor): adobe/da-live#1224

@rofe
rofe marked this pull request as draft August 28, 2026 09:42
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.

[env-switcher] Persist hash when switching environments; carry text selection into DA editor

1 participant