Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

First-class (partial) text selection support on mobile (iOS) for `<html.p />`, `<html.h1 />`, `<html.span />`, et al

オープン
#474 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
javascript, react-native
領域
frontend, mobile

調査の方向性

createStrictDOMTextComponent のエントリーポイントから始め、createStrictDOMTextInputComponent と比較してから、issue にある最小限の Expo/iOS の例を再現します。ネイティブの HTML テキスト要素が React Native コンポーネントにどのようにマッピングされるかを追跡し、提案されている selectable の opt-in 構造を評価します。完了時には、デフォルトの挙動や Web の挙動を変更せずに、iOS で部分的なネイティブテキスト選択を提供できるようにします。

索引モデルが issue の本文から書いたものです。

説明

Describe the feature request

On iOS (only mobile platform I've tested so far), let text-bearing html.* elements:

  • html.p
  • html.h1 ... html.h6
  • html.li
  • html.span
  • html.code
  • et al

...participate in the native partial-text-selection affordance:

  • drag to extend a range
  • selection handles
  • magnifier
  • ...and the system edit menu; i.e.:
    • Copy
    • Look Up
    • Translate
    • Share
    • Speak
    • Writing Tools

Same behaviour React Native for (Desktop) macOS already provides via react-native-macos's NSTextView (and that browsers provide on web).

iOS is the outlier.
Android: yet to be tested. (OpenHarmony, likely entirely out of scope).

Current behaviour

Setting userSelect: 'text' on a text-bearing html.* element on iOS surfaces the iOS edit menu on long-press, but only with Copy. There is no selection range: the menu opens directly, dragging does nothing, no magnifier, no handles. Tapping Copy copies the whole element's text rather than a chosen range.

Minimal reproduction (Expo SDK 55 + [email protected], iOS 16+):

import { html, css } from 'react-strict-dom';

const styles = css.create({
  p: { fontSize: 16, lineHeight: 1.45, userSelect: 'text' },
});

export default function Demo() {
  return (
    <html.p style={styles.p}>
      Long-press this paragraph on iOS. The system edit menu opens
      immediately with only `Copy`. No selection handles, no
      drag-to-extend, no magnifier. The same `html.p` on macOS
      supports full partial selection.
    </html.p>
  );
}

Why it matters

The asymmetry breaks consistent UX across the platforms RSD targets:

Platform Partial selection System edit menu
Web ✅ browser default ✅ browser default
macOS (react-native-macos) ✅ NSTextView default ✅ AppKit default
iOS (react-native) ❌ Copy only
Android (react-native) ❌ ([likely] out of scope here)

For any reader-oriented surface (articles, chat messages, notes, markdown viewers, quoted replies) partial selection is table stakes. Users who experience macOS and iOS in the same app are particularly badly served by the gap.

Root cause

html.p / html.h1 ... html.h6 / html.li / html.span / html.code all map to react-native's Text on native (createStrictDOMTextComponent → Text). React Native's iOS Text is RCTParagraphComponentView (Fabric) / RCTTextView (legacy): a custom UIView that draws via NSLayoutManager. It doesn't implement UITextInteraction, so iOS has nothing to attach selection handles to.

The well-known RN-iOS workaround for partial-text selection is <TextInput editable={false} multiline selectable />, backed by UITextView and inheriting full selection + native edit menu. RSD already maps html.input and html.textarea to TextInput via createStrictDOMTextInputComponent: the primitive is right there; it just isn't what static text elements compile to.

Proposed shapes (sketches, in increasing invasiveness)

  1. New selectable HTML prop, opt-in: RSD adds a selectable boolean prop to text elements; when true on iOS, the underlying renderer wraps the content in a read-only TextInput. Default false; web semantics unchanged.

    <html.p selectable>…</html.p>
    
  2. Render-mode escape hatch: a new prop or variant that lets a consumer opt into TextInput-backed rendering for paragraphs / headings they want fully selectable. More general than a single boolean

  3. Map userSelect: 'text' (or other) to TextInput-readonly on iOS automatically: most magical, most spooky-action-at-a-distance; possibly breaks consumers relying on Text-specific layout behaviour that TextInput-readonly approximates rather than matches

"1" seems like the cleanest first cut: opt-in, doesn't change defaults, matches the platform reality that "selectable static text on iOS" is a distinct rendering choice rather than a free property of Text.

Workarounds (naive assumptions...)

  • <TextInput editable={false} multiline selectable /> used directly (canonical RN-iOS pattern, but bypasses RSD's semantic mapping)
  • react-native-selectable-text: community library wrapping the above
  • Conditional renderers that swap RSD primitives for RN's TextInput on iOS: works but pushes platform-divergence into consumer code

All of these work, but each lives outside RSD's surface. The gap is a consistent, RSD-supported way to mark static text as selectable that handles the platform divergence so consumers don't have to.

Related / "Prior Art"

  • React Native issue #23147 (closed): original observation that selection ranges aren't exposed on Text; the RN team's answer was effectively "use TextInput read-only," which is the right RSD-side answer if you accept that rendering choice
  • RSD's recent input-side setSelectionRange / selectionStart / selectionEnd polyfill work (commit 65e439b, Dec 2025) shows selection is on the roadmap on the input side; static-text selection is the natural companion

(Likely) Out of scope

  • Editor/ cursor/keyboard navigation (these need editable-true paths and are larger)
  • Android partial selection (related, but RN-Android has its own constraints; deserves a separate issue)
  • Selection-event callbacks (onSelectionChange on static text): useful, but layerable on top of basic selection support
主要言語
JavaScript
スター
3.6k
フォーク
208
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

react/react-strict-dom のほかの issue

react/react-strict-dom の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。