3

Say you're writing a comment. You type this text:

The foo is a bar a la baz.

Now, you want to put "bar" in a code block, so you tap and hold, click Format, then click Code. It seems to work – your text is wrapped in backticks, so it's probably going to end up in a code block.

You post the comment without deselecting the text, give it a paranoid once-over for spelling mistkaes, and see that what got posted was this:

The foo is a `` a la baz.

So you edit your comment and add bar back in.

When it's just a word or two, it's not that bad, but when you're, say, asking about a bit of syntax and retype it, it's easy to get irritated that the whole thing apparently randomly got deleted.

This can also cause comments to dip below the 15-character limit, which seems to imply that this is done before any validation.

Note that it doesn't just happen with code blocks – try just selecting some text and posting a comment with that text selected.

To reproduce:

  1. Open the iOS app.
  2. Load any post.
  3. Create a new comment.
  4. Select some portion of it
  5. Immediately tap on "Go" on the keyboard, without tapping anywhere on the message.

This posts a comment with whatever text you have selected removed from it.

I'm using iOS 9.3.1 (13E238) according to the help screen. I believe I have the latest version of the SE app but I'm not sure.

  • I can repreoduce this – Downgoat May 11 '16 at 20:14
  • Testing this out. If you see this, I was right. – Nic Hartley May 21 '16 at 15:43
  • (for that comment, I wrote "if you see this, I was wrong right", then selected "wrong") – Nic Hartley May 21 '16 at 15:43
  • 1
    Doesn't happen from desktop. – ArtOfCode May 21 '16 at 15:44
2

This will be fixed in 1.5.0.2.

When you press Send, the default behavior of the keyboard acts as a return key, attempting to replace the current content with a line break. We were allowing the replacement to take place and then performing the submission. Basically:

- (void)textViewDidChange:(UITextView *)textView
{
    if ([textView.text contains:@"\n"]) {
        [self submitComment];
    }
}

Instead, we are now capturing the request to replace the current selection with a line break, saying no, and submitting the comment:

// http://stackoverflow.com/a/7315644/860000
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) {
        [self submitComment];
        return NO;
    }

    return YES;
}

You can try this change when it's built by becoming a beta tester.

  • Oh, that's a neat change, and a bug I'd never have figured out. Thanks for fixing it! (WRT beta testing: heck yeah!) – Nic Hartley May 26 '16 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .