Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(Dialog): support nested Dialogs and Popups#1706

Merged
layershifter merged 14 commits intomasterfrom
fix/dialog-nesting
Jul 23, 2019
Merged

fix(Dialog): support nested Dialogs and Popups#1706
layershifter merged 14 commits intomasterfrom
fix/dialog-nesting

Conversation

@layershifter
Copy link
Member

@layershifter layershifter commented Jul 23, 2019

Fixes #1674.

This PR:

  • fixes matching bug via usage of Unstable_NestingAuto component, same thing as in Popup
  • adds a new prototype with different behaviors of nested Popups and Dialogs
  • adds E2E for fixed behavior 🚀

export type GetContextRefs = (needleRef: NodeRef) => NodeRef[]
export type GetRefs = () => NodeRef[]
export type NodeRef<T extends Node = Node> = React.RefObject<T>
export type NodeRef<T extends Node = Node> = React.MutableRefObject<T>
Copy link
Member Author

Choose a reason for hiding this comment

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

There refs are mutable, it allows to avoid usage of handleRef or @tsignore

"module": "esnext"
},
"include": ["../packages/react/src", "../e2e", "../types"]
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Add tsconfig.json to get proper autocomplete

@@ -1,29 +0,0 @@
import * as React from 'react'
Copy link
Member Author

Choose a reason for hiding this comment

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

Cruft, this function is a part of @stardust-ui/react-component-ref

export type TriggerAccessibility = {
attributes?: AccessibilityAttributes
keyHandlers?: AccessibilityKeyHandlers
keyHandlers?: AccessibilityHandlerProps
Copy link
Member Author

Choose a reason for hiding this comment

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

Type was wrong previously

e2e/e2eApi.ts Outdated
return { x: Math.round(rect.left), y: Math.round(rect.top) }
}, selector)

await this.page.mouse.click(dimensions.x + x, dimensions.y + y)
Copy link
Member Author

Choose a reason for hiding this comment

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

https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageclickselector-options

This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the method throws an error.

To make this test working I need a different behavior because the center of overlay is content and click will be ignored

@codecov
Copy link

codecov bot commented Jul 23, 2019

Codecov Report

Merging #1706 into master will decrease coverage by <.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1706      +/-   ##
==========================================
- Coverage   71.17%   71.17%   -0.01%     
==========================================
  Files         858      858              
  Lines        7106     7111       +5     
  Branches     2033     2054      +21     
==========================================
+ Hits         5058     5061       +3     
- Misses       2042     2044       +2     
  Partials        6        6
Impacted Files Coverage Δ
packages/react/src/components/Portal/Portal.tsx 100% <ø> (ø) ⬆️
packages/react/src/components/Popup/Popup.tsx 65.71% <100%> (ø) ⬆️
packages/react/src/components/Dialog/Dialog.tsx 34.88% <45.45%> (+3.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c671a74...5614eb8. Read the comment docs.

@layershifter layershifter added 🧰 fix Introduces fix for broken behavior. 🚀 ready for review labels Jul 23, 2019
Co-Authored-By: Marija Najdova <mnajdova@gmail.com>
Co-Authored-By: Marija Najdova <mnajdova@gmail.com>
Copy link
Contributor

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Changed look good to me, please check one last time with accessibility team whether everything works as expected

@layershifter
Copy link
Member Author

Confirmed this with @jurokapsiar, however we found another issue #1709 that should be fixed separately.

@layershifter layershifter merged commit 5afe10c into master Jul 23, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix/dialog-nesting branch July 23, 2019 16:12
layershifter added a commit that referenced this pull request Jul 23, 2019
* add nesting registry

* wip

* add prototype

* add E2E tests

* remove console.log

* add changelog entry

* fix dangerjs issue

* Update e2e/tests/dialogInPopup-test.ts

Co-Authored-By: Marija Najdova <mnajdova@gmail.com>

* Update e2e/tests/dialogInDialog-test.ts

Co-Authored-By: Marija Najdova <mnajdova@gmail.com>

* update test header

* use boundingBox

* update method

(cherry picked from commit 5afe10c)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🧰 fix Introduces fix for broken behavior. 🚀 ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Click inside a child Dialog of a Popup closes the whole React tree

3 participants