Skip to content

Conversation

michenly
Copy link
Contributor

@michenly michenly commented Nov 29, 2018

WHY are these changes introduced?

Resolves #669 (comment)

WHAT is this pull request doing?

Added forceRender to title, breadcrumbs, and actions render in the app when app-bridge is use

Default using app bridge
ie. <AppProvider apiKey={YOUR_API_KEY}>
by default

Default without app bridge
ie. <AppProvider apiKey={undefined}>
with both

Using app bridge & forceRenderTitle
ie. <AppProvider apiKey={YOUR_API_KEY}><Page title="test title" forceRenderTitle /></AppProvider>
with forcerendertitle

Using app bridge & forceRenderActions
ie. <AppProvider apiKey={YOUR_API_KEY}><Page title="" primaryAction={{content: 'Save'}} forceRenderActions /></AppProvider>
with forcerenderactions

Using app bridge, forceRenderTitle, and forceRenderActions
ie. <AppProvider apiKey={YOUR_API_KEY}><Page title="test title" primaryAction={{content: 'Save'}} forceRenderTitle forceRenderActions /></AppProvider>
with both

Using app bridge, forceRender
ie. <AppProvider apiKey={YOUR_API_KEY}><Page title="test title" primaryAction={{content: 'Save'}} forceRender /></AppProvider>
with both

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Copy-paste this code in playground/Playground.tsx:
import * as React from 'react';
import {Page} from '@shopify/polaris';

interface State {}

export default class Playground extends React.Component<never, State> {
  render() {
    return (
      <AppProvider apiKey={YOUR_API_KEY}>
          <Page title="Playground" breadcrumbs={[{content: 'previous page'}]} primaryAction={{content: 'Save'}}>
            {/* Add the code you want to test here */}
          </Page>
      </AppProvider>
    );
  }
}

🎩 checklist

@michenly michenly self-assigned this Nov 29, 2018
@BPScott BPScott temporarily deployed to polaris-react-pr-695 November 29, 2018 19:21 Inactive
@michenly michenly changed the title [Page][WIP] ✨ add forceRenderTitle && forceRenderActions to control if the re… [Page][Prototype] ✨ add forceRenderTitle && forceRenderActions to control if the re… Nov 29, 2018
@michenly michenly force-pushed the force-render-in-page branch from ba03408 to 89c3895 Compare November 29, 2018 19:31
@BPScott BPScott temporarily deployed to polaris-react-pr-695 November 29, 2018 19:31 Inactive
@michenly michenly requested a review from tmlayton November 30, 2018 16:02
@resistorsoftware
Copy link

resistorsoftware commented Nov 30, 2018

I am using latest Polaris 3.1.1 and my Page component is not respecting this idea of forceRenderingActions seriously.. my setup is..

<Page
    title="Dashboard"
    icon={this.props.inventory.icon}
    primaryAction={{content: 'Recommendations', target: 'APP', url: '/recommendations'}}
    forceRenderActions
  >

And yet my primaryAction button is rendering in that ugly separate top heading bar... what? I am now super confused. I am using AppProvider with an API key, so this is App Bridge enabled. Whatever that means. I am so disappointed at the level of confusion introduced by all these breaking changes it is disheartening to say the least.

@michenly
Copy link
Contributor Author

michenly commented Dec 3, 2018

@resistorsoftware the idea of forceRenderActions is only in this PR and and is meant to be a possible way of addressing exactly the confusion you mention above.

This is unfortunately not part of Polaris 3.1.1 yet so the only way to see forceRenderActions in action is pulling this branch locally.

There are a few work around mentioned in #669 to have this working today. (I personally like #669 (comment) the most)

I hope this help!

@resistorsoftware
Copy link

Thanks @michelleyschen

Personally, I hate wasting my time, and using workarounds is just that. I am not into re-visiting work a few months or longer down the road to simply remove workarounds that fix what should be fixed for real, now.

I am seeing countless complaints and errors and bugs with App Bridge et al... including what happened last night. The button I see (rendered in the "wrong" place belongs to a completely different App running in a different tab, in the same shop!

I am uncomfortable being a guinea pig as the Shopify team attempts to bring the App Bridge to life, and also, I am not pleased the documentation and directions do not follow when implementing Polaris. It should be WYSIWYG but instead, as this shows, it is more like chaos.

(breadcrumbs != null && breadcrumbs.length > 0)
);
const hasHeaderTitle =
title != null && title !== '' && (appBridge ? forceRenderTitle : true);
Copy link

@amooz amooz Dec 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note: whenever you're comparing the string '', always consider if you need to trim() the string first to avoid bugs using extra spaces at the end. I think this check will pass if title is " ", which doesn't look like the desired behaviour? Could be wrong, though! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is the existing logic in Polaris, I am un-sure about changing the check @tmlayton double checking if this is the desired behaviour or can I introduce the trim check?

@resistorsoftware
Copy link

Do we have to wait till 2019 for Polaris to work with an Embedded App and Page component? Why is it taking so long to fix and make it consistent with the dreams and documentation?

@tmlayton
Copy link
Contributor

@michelleyschen I’d prefer to keep this approach a bit simpler where forceRender skips delegation to App Bridge entirely. Then if an app still wants to use App Bridge’s TitleBar, they can pull the appBridge instance off of context and interact with app bridge directly.

Personally, I’m leaning heavily towards removing app bridge from Polaris entirely. It seems to have caused more issues and confusion than it has been helpful. I’m thinking we would still provide a set of React components which wrap app bridge (maybe even keep the same names), as well as an AppBridgeProvider for instantiation. Wherever these components live, we can move the ShopifyRoutePropagator there as well.

@resistorsoftware the criticisms are appreciated. Given I did most of the work integrating App Bridge with Polaris, it’s disappointing it hasn’t gone smoothly. It’s a fair point about being forced into early adoption (guinea pig) with App Bridge. While App Bridge is ultimately the path forward at Shopify, we were too optimistic including it in v3.0.0 as App Bridge was being launched.

That being said, this is a pull request. Please keep comments specific to @michelleyschen’s approach to force-rendering <Page /> when in an embedded context and direct issues and criticisms to either GitHub issues or, for App Bridge specifically, the Shopify APIs & SDKs forum.

/** Decreases the maximum layout width. Intended for single-column layouts */
singleColumn?: boolean;
/** Force render of title and breadcrumbs in page on embedded app, default false */
forceRenderTitle?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking only a forceRender prop which simply skips app bridge delegation.

@vividviolet vividviolet requested review from gf3 and vividviolet January 2, 2019 21:08
@katbuilt
Copy link

katbuilt commented Jan 2, 2019

@michelleyschen -- I chatted with @nwtn about this and I'm very supportive of this from a Merchant Experience of Apps perspective. I have two clarifying questions though:

  1. The screenshots here only show the placement of primary action in relation to breadcrumb and title (purple button) Could you post some screenshots of what happens when there are primary actions and the maximum number of allowed secondary action buttons? What about apps using pagination?

  2. What would be the backwards-facing implications of this PR to apps who don't add the forceRender to their app code?

Thank you!

@vividviolet
Copy link
Member

vividviolet commented Jan 2, 2019

I am seeing countless complaints and errors and bugs with App Bridge et al... including what happened last night.

@resistorsoftware can you clarify who is complaining? Is is the merchant or app developers?

The button I see (rendered in the "wrong" place belongs to a completely different App running in a different tab, in the same shop!

Can you please log an issue in this repo so we can dig into it?

Personally, I’m leaning heavily towards removing app bridge from Polaris entirely. It seems to have caused more issues and confusion than it has been helpful

I created a new issue so we can discuss removing App Bridge from Polaris #814

@michenly
Copy link
Contributor Author

michenly commented Jan 7, 2019

@katbuilt

The screenshots here only show the placement of primary action in relation to breadcrumb and title (purple button) Could you post some screenshots of what happens when there are primary actions and the maximum number of allowed secondary action buttons? What about apps using pagination?

The forceRender meant the app will render like any app without app bridge connection. So the actions buttons & pagination will work exactly like what the Page component listed on polaris guide. https://polaris.shopify.com/components/structure/page#navigation

What would be the backwards-facing implications of this PR to apps who don't add the forceRender to their app code?

Any app or Page that does not have forceRender will continue to work like today.

@michenly michenly force-pushed the force-render-in-page branch 3 times, most recently from 55129f5 to 91da6f3 Compare January 7, 2019 19:09
@michenly michenly changed the title [Page][Prototype] ✨ add forceRenderTitle && forceRenderActions to control if the re… [Page][Prototype] ✨ add forceRender && forceRenderActions to control if the re… Jan 7, 2019
@michenly michenly changed the title [Page][Prototype] ✨ add forceRender && forceRenderActions to control if the re… [Page][Prototype] ✨ add forceRender to force render of the title, actions & breadcrumbs to be in page vs in the top bar. Jan 7, 2019
@michenly
Copy link
Contributor Author

michenly commented Jan 7, 2019

@tmlayton update the code to just have forceRender prop. The build-consumer seems to be broken, how have you been testing appBridge related things recently?

@michenly michenly closed this Jan 7, 2019
@michenly michenly deleted the force-render-in-page branch January 7, 2019 19:15
@michenly michenly restored the force-render-in-page branch January 7, 2019 19:16
@michenly michenly reopened this Jan 7, 2019
Copy link
Contributor

@tmlayton tmlayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment about the doc link and looks like a bad rebase of the changelog, otherwise this looks fine.

@keyfer keyfer force-pushed the force-render-in-page branch from 5a3ad42 to 3d70a01 Compare January 18, 2019 16:57
@BPScott BPScott temporarily deployed to polaris-react-pr-695 January 18, 2019 16:57 Inactive
@tmlayton
Copy link
Contributor

Changelog is still including entries that have since been released

@BPScott BPScott temporarily deployed to polaris-react-pr-695 January 22, 2019 14:45 Inactive
@keyfer keyfer force-pushed the force-render-in-page branch from ee2e47a to 0e9a9fa Compare January 22, 2019 14:46
@BPScott BPScott temporarily deployed to polaris-react-pr-695 January 22, 2019 14:47 Inactive
@keyfer
Copy link
Contributor

keyfer commented Jan 22, 2019

Don't know how I missed that twice, sorry @tmlayton.

Should be good now.

@keyfer keyfer force-pushed the force-render-in-page branch from 0e9a9fa to 83c489d Compare January 22, 2019 14:48
@BPScott BPScott temporarily deployed to polaris-react-pr-695 January 22, 2019 14:48 Inactive
Copy link
Contributor Author

@michenly michenly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't approve this since I am the original author lol

* Force render in page and do not delegate to the app bridge TitleBar action
* @default false
* @embeddedAppOnly
* @see {@link https://polaris.shopify.com/components/structure/page#section-use-in-an-embedded-application|Shopify Page Component docs}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we...updating the doc in this link?

@BPScott BPScott temporarily deployed to polaris-react-pr-695 January 22, 2019 16:43 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-695 January 22, 2019 16:45 Inactive
@keyfer keyfer force-pushed the force-render-in-page branch from 7bdb805 to b22ee3e Compare January 22, 2019 16:45
@BPScott BPScott temporarily deployed to polaris-react-pr-695 January 22, 2019 16:46 Inactive
@keyfer keyfer requested a review from tmlayton January 22, 2019 16:47
@keyfer keyfer force-pushed the force-render-in-page branch from b22ee3e to bde9e30 Compare January 23, 2019 18:31
@BPScott BPScott requested a deployment to polaris-react-pr-695 January 23, 2019 18:32 Abandoned
@BPScott BPScott requested a deployment to polaris-react-pr-695 January 23, 2019 18:33 Abandoned
@keyfer keyfer force-pushed the force-render-in-page branch from b879ffe to 9566549 Compare January 23, 2019 18:34
@BPScott BPScott requested a deployment to polaris-react-pr-695 January 23, 2019 18:34 Abandoned
@keyfer keyfer merged commit c244612 into master Jan 23, 2019
@ghost
Copy link

ghost commented Jan 23, 2019

🎉 Thanks for your contribution to Polaris React!

@keyfer keyfer deleted the force-render-in-page branch January 23, 2019 18:39
@keyfer keyfer changed the title [Page][Prototype] ✨ add forceRender to force render of the title, actions & breadcrumbs to be in page vs in the top bar. [Page]✨ add forceRender to force render of the title, actions & breadcrumbs to be in page vs in the top bar. Feb 5, 2019
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

Successfully merging this pull request may close these issues.

8 participants