-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Graduate Labs Components - Part 2: Replace Popover/Tooltip with Popover2/Tooltip2 #1891
Conversation
packages/core/src/common/errors.ts
Outdated
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this 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
packages/core/karma.conf.js
Outdated
@@ -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/*", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Add 'packages/*/node_modules/' to save_cache dirsPreview: documentation | table |
Merge branch 'master' into cl/graduate-labs-to-core-2Preview: documentation | table |
Cache bust: v5 => v6Preview: 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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DERP.
Undo singlRun flag changePreview: documentation | table |
Revert changes to Circle config filePreview: documentation | table |
Fix table testsPreview: documentation | table |
@adidahiya @giladgray ready for actual CR now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review.
packages/core/src/common/errors.ts
Outdated
@@ -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. |
There was a problem hiding this comment.
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" }, |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it default explicitly to false
below?
</MenuItem>, | ||
childContainer, | ||
) as MenuItem; | ||
</React.Fragment>, |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
Fix build (was due to errant find+replace), fix commentPreview: documentation | table |
There was a problem hiding this 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:
@@ -33,13 +46,13 @@ describe("<Popover>", () => { | |||
testsContainerElement.remove(); | |||
}); | |||
|
|||
describe("validation:", () => { | |||
describe.skip("validation:", () => { |
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
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
Fix inline popover targets (CSS)Preview: documentation | table |
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). |
Flaked again. Opened this PR to (hopefully) fix the flaky |
Tooltip
andPopover
fromcore/
Popover2
andTooltip2
toPopover
andTooltip
, respectivelytether
dependencyisDisabled
,useModal
,hasBackdrop
)Note:
Context Menu
is super screwy now; its calculatedtransform
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):
Migrate deprecated internal usages to new props (e.g.(done in this PR after all)Popover2.isDisabled
).Tooltip2
,Popover
,TagInput
, and remove them from karmacoverageExcludes
; bring back old documentation that is still relevant.