-
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
ContextMenu fixes & Overlay didClose #2399
Changes from all commits
bb3c258
0002959
313c66d
5e24bcf
f1db218
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,18 @@ describe("ContextMenu", () => { | |
assertContextMenuWasRendered(); | ||
}); | ||
|
||
it("invokes onClose callback when menu closed", () => { | ||
const onClose = spy(); | ||
ContextMenu.show(MENU, { left: 0, top: 0 }, onClose); | ||
it("invokes onClose callback when menu closed", done => { | ||
ContextMenu.show(MENU, { left: 0, top: 0 }, done); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feels a little odd to me to do things this way w/o an assertion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a pattern i see frequently in other test suites: it essentially asserts that the callback is called at all. if it's not called then it will time out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 seems reasonable, I didn't know the exact timeout behavior |
||
ContextMenu.hide(); | ||
}); | ||
|
||
it("removes element from the DOM after closing", done => { | ||
ContextMenu.show(MENU, { left: 0, top: 0 }); | ||
ContextMenu.hide(); | ||
assert.isTrue(onClose.calledOnce, "onClose not called"); | ||
setTimeout(() => { | ||
assert.isTrue(document.querySelector(`.${Classes.CONTEXT_MENU}`) == null); | ||
done(); | ||
}, 110); | ||
}); | ||
|
||
it("does not invoke previous onClose callback", () => { | ||
|
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.
is it better to make this "div" so as not to break shallow comparison of props for updates? though you'd also need to change
backdropProps
aboveThere 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 don't understand the action item here. i could make it a static constant?
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.
or just make it
"div"
, right?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.
but either way, prop comparison will never be equal because of
backdropProps
aboveThere 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.
"div"
is quite different from<div />
here... one would appear as three letters in the DOM, the other is an empty element.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.
ah, I see, you have to use
targetElementTag
for that?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.
targetElementTag
is actually the parenttarget
prop, and a target is required so you can't just set that prop