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

TextView crashes app because textAttachmentDelegate? not set. #1397

Open
srosenbaumCB opened this issue Jul 1, 2024 · 0 comments
Open

TextView crashes app because textAttachmentDelegate? not set. #1397

srosenbaumCB opened this issue Jul 1, 2024 · 0 comments

Comments

@srosenbaumCB
Copy link

Describe the bug

TextView func storage(_ storage: TextStorage, placeholderFor attachment: NSTextAttachment) -> UIImage is crashing my app in production of the following guard statement contains a fatalError.

        guard let textAttachmentDelegate = textAttachmentDelegate else {
            fatalError("This class requires a text attachment delegate to be set.")
        }

        return textAttachmentDelegate.textView(self, placeholderFor: attachment)

The problem with this is that earlier in the file the following is explicitly stated for the textAttachmentDelegate optional.

    /// The media delegate takes care of providing remote media when requested by the `TextView`.
    /// If this is not set, all remove images will be left blank.
    ///
    open weak var textAttachmentDelegate: TextViewAttachmentDelegate?

Which would imply that the TextView will continue to function, only without displaying images. Not fatalError crashing.

This seems to be the case with all of the storage functions.

To Reproduce
Steps to reproduce the behavior:
1.

Create an instance of the TextView without instantiating textAttachmentDelegate

  1. Render the Field in a SwiftUI view.

Expected behavior
A clear and concise description of what you expected to happen.

A TextView should continue to run rendering the HTML and images remain blank, WITHOUT crashing the app, as implied by the documentation. (Unless there is actually something called 'remove images'.)

Screenshots
If applicable, add screenshots to help explain your problem.
simulator_screenshot_BCB48876-BD8C-45A0-AE68-F9D31201CD38

Smartphone (please complete the following information):

  • Device: iPhone 15 Pro
  • OS: 17.5.1

Additional context
Add any other context about the problem here.

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

No branches or pull requests

1 participant