Wordpress-ios: Editor: New post button is not always context-aware, defaults to primary site

Created on 31 May 2016  ·  7Comments  ·  Source: wordpress-mobile/WordPress-iOS

Expected behavior

When I disable Visual Editor in App Settings, then go to a site -> Blog Posts, I'd expect tapping the + (plus) icon in the top right to start a new post in that site.

Actual behavior

Instead, the plus icon starts a new post in my primary site — with no way to change it.

Steps to reproduce the behavior

  1. Disable Visual Editor in App Settings
  2. Click to Sites, select a non-primary site
  3. Go to Blog Posts (also happens in Pages)
  4. Click the plus icon to start a new post or page
  5. Look at the top of the view: this post is going to your primary site and not the current site

I found this out after accidentally publishing to my primary blog. Luckily I caught it and deleted it right away.

Starting by disabling settings:

This is the site I want to post to:

Note: wrong site! This isn't the same one (but it's my primary site)

Tested on [device], iOS [version], WPiOS [version]

iPhone 6+, 9.3.2, 6.3.0.20160524

PostinEditing [Pri] High [Type] Broken Window [Type] Bug

All 7 comments

Hmm — might be a false alarm. :/ After going back to sites list a few times, now it seems to be working as expected.

I reproduced the issue the first two times I tried it. In those cases, I was already on a different site (not primary site) before disabling the visual editor. Here were my steps:

  1. Disable visual editor in app settings
  2. Tap the WordPress icon to go to My Sites section
  3. I was already in the dashboard for a non-primary site, so select Blog Posts
  4. Tap plus icon to start a new post

Result: A new post was started for my primary site

I then closed the editor and continued:

  1. Go back to site picker
  2. Select a different non-primary site
  3. Select Blog Posts
  4. Tap plus icon to start a new post

Result: A new post was started for the site I had selected

This feels like a familiar issue but I can't find a related report.

Tested on iPhone 6, iOS 9.3.2, WPiOS 6.3.0.20160524

I'm not sure this is the same issue, but this morning I ran into a similar problem while the visual editor was enabled:

  1. I opened the My Sites section and was already on a non-primary blog
  2. I tapped the Editor icon in the bottom navigation bar

Result: A new post was started for my primary site

I then closed the editor and continued:

  1. I selected Blog Posts for the non-primary site
  2. I tapped the plus icon to start a new post

Result: A new post was started for the correct (non-primary) site

I went back and forth, and the editor icon kept opening the editor for the wrong site. When I went back to the site picker and re-selected the same non-primary site, both the editor icon and the plus icon opened the editor for the correct site.

I think this is somehow related to the app's state when you open it and have a non-primary site already selected in the My Sites section.

Looking at the code I see some spots where the logic might be wrong. By default, the post button will create a post in the last used blog, and fall back to primary, or the first blog in the list if there's no primary.

The problem might lie in the "last used" flag, which is set in 3 scenarios:

  • When you tap on a site on the sites list
  • When you select a blog on the blog selector
  • Every time the primary blog detail is configured, which is every time the account details are synced, which happens... often 🤦‍♂️

That last one was definitely a surprise, and probably the cause of this, but there's also another possible scenario:

  • Go to blogs list, tap on site A (lastUsed: A)
  • Go to posts, create a post
  • From the editor, change the site to B (lastUsed: B)
  • Post or dismiss the editor
  • You are now viewing site A, but tapping on the post button would create a post in site B

So just to clarify the desired behavior:

  • If the "My Sites" tab is selected, and we're inside a specific site, always post to that site
  • If looking at the sites list or any other tab, post to the last used site (with fallback to primary/first site)

Does that sound right?

Yes that sounds right to me, so if I go to my photo blog (not my primary site), then tap the reader, then tap "new post", it'll post to the photo blog?

To clarify "Every time the primary blog detail is configured" - that's going to be removed?

To clarify "Every time the primary blog detail is configured" - that's going to be removed?

Yes. I think the logic was that when you sign in, it'd mark the primary blog as the "last used", but even if that was the case I don't think that's what we'd want.

That sounds good to me. Thanks for clarifying.

Was this page helpful?
0 / 5 - 0 ratings