Skip to content

Conversation

@tmlayton
Copy link
Contributor

@tmlayton tmlayton commented Oct 5, 2019

WHY are these changes introduced?

Fixes #2245

WHAT is this pull request doing?

Only clear timeouts if active prop changes. See the regression test failure in the first commit, then the code to satisfy the regression in the second commit.

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Copy-paste this code in playground/Playground.tsx:
import React, {useState, useCallback} from 'react';
import {Page, Popover, Button, ActionList} from '../src';

export function Playground() {
  const [popoverActive, setPopoverActive] = useState(true);
  const [sectioned, setSectioned] = useState(false);

  const togglePopoverActive = useCallback(() => {
    setPopoverActive((popoverActive) => !popoverActive);
    setTimeout(() => setSectioned((sectioned) => !sectioned), 50);
  }, []);

  const activator = (
    <Button onClick={togglePopoverActive} disclosure>
      More actions
    </Button>
  );

  return (
    <Page title="Playground">
      <div style={{height: '250px'}}>
        <Popover
          active={popoverActive}
          activator={activator}
          onClose={togglePopoverActive}
          sectioned={sectioned}
        >
          <ActionList items={[{content: 'Import'}, {content: 'Export'}]} />
        </Popover>
      </div>
    </Page>
  );
}

🎩 checklist

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2019

💦 Potential splash zone of changes introduced to src/**/*.tsx in this pull request:

Files modified3
Files potentially affected24

Details

All files potentially affected (total: 24)
📄 UNRELEASED.md (total: 0)

Files potentially affected (total: 0)

🧩 src/components/Popover/components/PopoverOverlay/PopoverOverlay.tsx (total: 24)

Files potentially affected (total: 24)

🧩 src/components/Popover/components/PopoverOverlay/tests/PopoverOverlay.test.tsx (total: 0)

Files potentially affected (total: 0)


This comment automatically updates as changes are made to this pull request.
Feedback, troubleshooting: open an issue or reach out on Slack in #polaris-tooling.

Copy link
Contributor

@dleroux dleroux left a comment

Choose a reason for hiding this comment

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

Code makes sense and 🎩in web looks good! Thanks for jumping on this @tmlayton.

@tmlayton tmlayton merged commit aed5728 into master Oct 7, 2019
@tmlayton tmlayton deleted the pop-fix branch October 7, 2019 17:35
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.

[Popover] Overlay still in DOM if updated while exiting

3 participants