Skip to content

Conversation

AndrewMusgrave
Copy link
Member

@AndrewMusgrave AndrewMusgrave commented Mar 21, 2019

WHY are these changes introduced?

  • Removes outdated lifecycle method
  • fixes a bug that keep default action title / hint when removed

WHAT is this pull request doing?

Taking advantage of getDerivedStateFromProps and adding additional logic to handle the bug fix

How to 🎩

Is my logic 🔉 ? Try examples and playground code (on master) - see how after the original default hint and title are shown, they won't show again after you set a hint / title. Even when removed.

Copy-paste this code in playground/Playground.tsx:
import * as React from 'react';
import {
  Page,
  TopBar,
  Layout,
  SettingToggle,
  ContextualSaveBar,
  TextStyle,
  Frame,
  AppProvider,
  DropZone,
  Button,
} from '../src';

interface State {}

export default class ProviderThemeExample extends React.Component {
  actionTitle = 'Action Title';
  actionHint = 'Action Hint';
  state = {
    actionTitle: this.actionTitle,
    actionHint: this.actionHint,
  };

  render() {
    const {actionHint, actionTitle} = this.state;

    return (
      <>
        <DropZone>
          <DropZone.FileUpload
            actionHint={actionHint}
            actionTitle={actionTitle}
          />
        </DropZone>
        <Button
          onClick={() => {
            this.setState({
              actionTitle:
                actionTitle === this.actionTitle ? undefined : this.actionTitle,
              actionHint:
                actionHint === this.actionHint ? undefined : this.actionHint,
            });
          }}
        >
          Change hint and title
        </Button>
      </>
    );
  }
}

@BPScott BPScott temporarily deployed to polaris-react-pr-1233 March 21, 2019 17:18 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1233 March 21, 2019 17:41 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1233 March 21, 2019 18:23 Inactive
Copy link
Contributor

@elileto elileto left a comment

Choose a reason for hiding this comment

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

Tophatted on multiple browsers and mobile. looks guuud.

@AndrewMusgrave AndrewMusgrave merged commit fe0c22c into master Apr 29, 2019
@AndrewMusgrave AndrewMusgrave deleted the fu-rm-cwrp branch April 29, 2019 20:38
@chloerice chloerice temporarily deployed to production May 8, 2019 19:57 Inactive
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.

4 participants