Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graduate Labs Components - Part 2: Replace Popover/Tooltip with Popover2/Tooltip2 #1891

Merged
merged 61 commits into from
Dec 19, 2017

Conversation

cmslewis
Copy link
Contributor

@cmslewis cmslewis commented Dec 12, 2017

  • Delete Tooltip and Popover from core/
  • Rename Popover2 and Tooltip2 to Popover and Tooltip, respectively
  • Delete tether dependency
  • Fix build failures.
  • Migrate deprecated internal usages to new props (isDisabled, useModal, hasBackdrop)

Note: Context Menu is super screwy now; its calculated transform offset is totally wrong. Can I get some help with the popper modifiers for context menus? Not sure I changed them properly.

Next steps (each in a separate PR, probably):

  1. Migrate deprecated internal usages to new props (e.g. Popover2.isDisabled). (done in this PR after all)
  2. Write tests for Tooltip2, Popover, TagInput, and remove them from karma coverageExcludes; bring back old documentation that is still relevant.

@@ -35,6 +35,7 @@ export const NUMERIC_INPUT_STEP_SIZE_NON_POSITIVE =
ns + ` <NumericInput> requires stepSize to be strictly greater than zero.`;
export const NUMERIC_INPUT_STEP_SIZE_NULL = ns + ` <NumericInput> requires stepSize to be defined.`;

// TODO (clewis): Delete old Popover errors that aren't used anymore.
Copy link
Contributor

Choose a reason for hiding this comment

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

can we get this resolved before merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@giladgray Turns out Popover2 doesn't use any of these. Seems like it should still handle these cases, so I'd be happy to leave these and file a follow-up issue. Thoughts?

@@ -1,281 +1,73 @@
@# Popovers
Copy link
Contributor

Choose a reason for hiding this comment

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

oh there's some very useful stuff in here that we don't want to delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, adding it back in Part 4.

Copy link
Contributor

Choose a reason for hiding this comment

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

wait what's part 3? is it possible to just not delete it now?

/**
* Prevents the popover from appearing when `true`.
* @deprecated use `disabled`
*/
isDisabled?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

lets just jump straight to the non-deprecated props

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

going to block on #1885

@@ -17,9 +17,9 @@ module.exports = function (config) {
"src/components/popover/*",
"src/components/tabs/*",
// TODO (clewis): write tests for these component as part of the 2.0 effort:
"src/components/popover2/*",
"src/components/popover/*",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is now a duplicate of line 17


@reactExample PopoverExample

@## JavaScript API
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we likely want to keep this entire section, and all its subsections, as they document key features of Popover that are still relevant.

@blueprint-bot
Copy link

Add 'packages/*/node_modules/' to save_cache dirs

Preview: documentation | table

@blueprint-bot
Copy link

Merge branch 'master' into cl/graduate-labs-to-core-2

Preview: documentation | table

@blueprint-bot
Copy link

Cache bust: v5 => v6

Preview: documentation | table

@@ -70,7 +70,7 @@ module.exports = function createKarmaConfig({ dirname, coverageExcludes, coverag
[path.join(dirname, "test/index.ts")]: "webpack",
},
reporters: ["mocha", "coverage"],
singleRun: true,
singleRun: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

questionable edit... this is probably why the tests are hanging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DERP.

@blueprint-bot
Copy link

Undo singlRun flag change

Preview: documentation | table

@blueprint-bot
Copy link

Revert changes to Circle config file

Preview: documentation | table

@blueprint-bot
Copy link

Fix table tests

Preview: documentation | table

@cmslewis
Copy link
Contributor Author

cmslewis commented Dec 19, 2017

image

image

@adidahiya @giladgray ready for actual CR now.

Copy link
Contributor Author

@cmslewis cmslewis left a comment

Choose a reason for hiding this comment

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

Self-review.

@@ -35,6 +35,7 @@ export const NUMERIC_INPUT_STEP_SIZE_NON_POSITIVE =
ns + ` <NumericInput> requires stepSize to be strictly greater than zero.`;
export const NUMERIC_INPUT_STEP_SIZE_NULL = ns + ` <NumericInput> requires stepSize to be defined.`;

// TODO (clewis): Delete old Popover errors that aren't used anymore.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@giladgray Turns out Popover2 doesn't use any of these. Seems like it should still handle these cases, so I'd be happy to leave these and file a follow-up issue. Thoughts?

const TETHER_OPTIONS = {
constraints: [{ attachment: "together", pin: true, to: "window" }],
const POPPER_MODIFIERS: PopperModifiers = {
preventOverflow: { boundariesElement: "window" },
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 these settings more or less equivalent to the old constraints?

export * from "./portal/portal";
export * from "./progress/progressBar";
export * from "./tooltip/svgTooltip";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adidahiya @giladgray React 16 was causing SVGTooltip and SVGPopover tests to fail, because they were trying to render <g> tags outside of an <svg>. Since these components are such thin wrappers around the core Tooltip and Popover, respectively, I opted just to delete them and consider adding documentation about working with these components in SVG land.

Does that sound okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

code search reveals a very small number (~5) of SVGPopover usages, and it's possible some of those are stale. I hate to say it, but I think we'll want to at least preserve support for this use case, which may require some work to be able to customize elements.

{...popoverProps}
content={submenuElement}
content={submenuRef}
minimal={true}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use the minimal prop instead of applying the pt-minimal class alone. This ensures the menu won't leave room for an arrow that doesn't even exist.

const parentWidth = this.liElement.parentElement.getBoundingClientRect().width;
const adjustmentWidth = submenuRect.width + parentWidth;
private maybeAlignSubmenuLeft() {
if (this.popoverRef == null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Small style improvement: put this check on top and de-intent everything below.

@@ -1,77 +1,7 @@
@# Tooltips
@# Tooltip
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will audit these docs and re-include relevant info in a follow-up PR.

@@ -1,17 +1,16 @@
/*
* Copyright 2015 Palantir Technologies, Inc. All rights reserved.
* Copyright 2017 Palantir Technologies, Inc. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

2015 because it's the same file in the diff? 2017 because that's when we wrote Tooltip2?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah lol I'm not sure! probably 2015 cuz it's the same file.

if (this.props.useSmartPositioning) {
// Popper.js renders the popover in the DOM before relocating its
// position on the next tick. We need to rAF to wait for that to happen.
requestAnimationFrame(() => this.maybeAlignSubmenuLeft());
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Popper.js should be powerful enough to handle all the positioning logic: we should let it decide when to flip to the left, because it likely knows better than us. Happy for this to be a follow-up, though.

@@ -1,281 +1,73 @@
@# Popovers
Copy link
Contributor

Choose a reason for hiding this comment

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

wait what's part 3? is it possible to just not delete it now?

@@ -1,17 +1,16 @@
/*
* Copyright 2015 Palantir Technologies, Inc. All rights reserved.
* Copyright 2017 Palantir Technologies, Inc. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah lol I'm not sure! probably 2015 cuz it's the same file.

* See http://github.hubspot.com/tether/#constraints
* @deprecated since v1.12.0; use `tetherOptions` instead.
* Initial opened state when uncontrolled.
* @default false
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this, it defaults to undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

</MenuItem>,
childContainer,
) as MenuItem;
</React.Fragment>,
Copy link
Contributor

Choose a reason for hiding this comment

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

✨ 😱 ✨

@@ -293,6 +290,15 @@ describe("MenuItem", () => {
function assertClassNameCount(className: string, count: number) {
assert.strictEqual(childContainer.queryAll(`.${className}`).length, count, `${count}x .${className}`);
}

function mountMenuItem(props?: IMenuItemProps, childItems?: React.ReactNode) {
return ReactDOM.render(
Copy link
Contributor

Choose a reason for hiding this comment

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

awkward we're not using enzyme here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@giladgray Looks like we need real DOM to properly evaluate all the real-estate-dependent dynamic-layout behavior. Also looks like you were the original test author, so feel free to tell me if that's not the case!

@blueprint-bot
Copy link

Fix build (was due to errant find+replace), fix comment

Preview: documentation | table

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

mostly looks good. I know this PR is getting long, but overall this feature isn't at the quality bar to merge into master. I think we should start a feature branch so we can push fixes in follow-up PRs. are you tracking all the remaining tasks in a list somewhere? we might want to make a new issue for that.

noticed this regression on the tooltip example:

2017-12-19 00 51 53

@@ -33,13 +46,13 @@ describe("<Popover>", () => {
testsContainerElement.remove();
});

describe("validation:", () => {
describe.skip("validation:", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

use { expectPropValidationError } from "@blueprintjs/test-commons";
fine to do in a follow-up PR, just make a note in this PR description

it("componentDOMChange does not update targetHeight/targetWidth state when useSmartArrowPositioning=false", () => {
const root = renderPopover({
useSmartArrowPositioning: false,
describe("deprecated prop shims", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

should remove this describe block in a follow-up PR

@cmslewis cmslewis changed the base branch from master to cl/graduate-labs-to-core December 19, 2017 19:26
@cmslewis cmslewis dismissed adidahiya’s stale review December 19, 2017 19:29

Addressed immediate comments

@blueprint-bot
Copy link

Fix inline popover targets (CSS)

Preview: documentation | table

@cmslewis
Copy link
Contributor Author

Unrelated test flake failed the build. I'll run it one more time and then just merge into my feature branch if it flakes again (I have a proposed fix for the flaky test btw; will open a new PR if it's foolproof).

@cmslewis
Copy link
Contributor Author

Flaked again. Opened this PR to (hopefully) fix the flaky Overlay test: #1943. Merging this for now.

@cmslewis cmslewis merged commit 351649c into cl/graduate-labs-to-core Dec 19, 2017
@cmslewis cmslewis deleted the cl/graduate-labs-to-core-2 branch December 19, 2017 19:52
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