Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify SelectionChangeObserver update logic #1095

Merged
merged 3 commits into from
Oct 3, 2023
Merged

Commits on Oct 2, 2023

  1. Always rely on the selectionchange API

    This removes the fallback to polling for selection changes. The selectionchange
    API has ben supported by all browsers that Trix supports for a long time now.
    The last browsers to add support for it was Firefox in version 52,
    and Chrome for Android, both in 2017.
    afcapel committed Oct 2, 2023
    Configuration menu
    Copy the full SHA
    33b4f9b View commit details
    Browse the repository at this point in the history
  2. Remove check for DOM range equality in SelectionChangeObserver

    This checks causes problems on Safari 17 when you drag the cursor to
    select text. Safari weirdly reports the selection range as being
    collapsed, even when you select multiple characters. This causes the
    SelectionManager to think that the selection is collapsed and not
    trying to find where it ends. The end result for the user is that
    they can not apply formatting or links to the whole selected text.
    
    This is ultimately a Safari bug, but it's not clear that we need to
    check for DOM range equality in the first place. The only reason we
    do this is because the original implementation of the
    SelectionChangeObserver used polling to check for selection changes,
    instead of relying on the `selectionchange` event. Now that we're
    using the `selectionchange` event, we can assume that if a selection
    change event fires, the selection has changed.
    afcapel committed Oct 2, 2023
    Configuration menu
    Copy the full SHA
    1a66aa0 View commit details
    Browse the repository at this point in the history
  3. Fix style violation

    afcapel committed Oct 2, 2023
    Configuration menu
    Copy the full SHA
    57312b8 View commit details
    Browse the repository at this point in the history