question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested portals should be discoverable

See original GitHub issue

This is more about a bridge between actual DOM Tree and React Tree.

Do you want to request a feature or report a bug? feature

What is the current behavior? You can portal a part of your rendering tree to another place in Dom Tree, and React would handle events, including events on Capture Phase like there were no portals - events could dive through all the react parents, and bubble up through all the react parents.

This is quite useful, as long as portal is an implementation detail, but useful only for normal events; there are more cases around it.

What is the expected behavior?

It’s better to explain it by example

  • you have a Modal Dialog and it uses a Focus Lock, ie focus could not leave it.
  • inside Modal you have a Custom Select, with Dropdown menu rendered via a portal.
  • you could not use it, as long as from DOM prospective ModalNode.contains(DropDownNode) is always false, and Focus Lock will prevent focusing.

It’s a real issue - https://github.com/reach/reach-ui/issues/83, https://github.com/theKashey/react-focus-lock/issues/19.

Proposed solution:

  • containsNode(domNode):boolean - React-aware version of DOM API node.contains(anotherNode).
  • getHostNodes():Nodes[] - returns a list of all root nodes inside “current component” including direct children and portals. Similar to ReactDom.findDomNode, and (proposed)refs attached to React.Fragment. It just finds all nodes “you are consists of”. As a result you will be able to tab from one piece of you to another, making focus management independed of implementation details.

Cons:

  • requires Component to access fiber, DOM node to access fiber thought node, or an new hook to do it in a functional way.
  • does twice dreadfull things than deprecated findDomNode
  • usage scope is very narrow.

Pros:

  • my use case requires momentum access to a rendered tree, and does not suffer async stuff as findDomNode, where underlaying node might not be yet created. Stuff like “does something containsNode right now”, or getHostNodes I consist from right now” are sync, and the question asked about actual DOM tree structure.

Example using react-dom-reflection, which implements required API - https://codesandbox.io/s/1or60v506l

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Never worked

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
diegohazcommented, Apr 11, 2020

Bump

0reactions
theKasheycommented, Dec 15, 2022

I also ended up managing portals from the user space via ContextApi/subscriptions, but while such solution works perfectly - it works perfectly only for me and cannot be shared with some third-party library as it is “not standard”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FileMaker Nested Portal - YouTube
Your browser can 't play this video. ... Information: This FileMaker tutorial is going to show you how create a multi-level nested portal....
Read more >
Planning your SharePoint hub sites - Microsoft Learn
Hubs are an important building block for your intranet. Here are some ways you can make your hub sites discoverable: Add hubs to...
Read more >
Chapter 2. Client Failover Red Hat AMQ 6.3 | Red Hat Customer Portal
Specifies extra options that can be added to the nested URLs. see Example ... Makes the broker discoverable by other brokers over the...
Read more >
DiscoveredPortalActivity (Oracle Fusion Middleware Java API ...
Activity that can be used to query or view portal that are discoverable. Nested Class Summary. Nested classes/interfaces inherited from interface ...
Read more >
NSF Arctic Data Center Frequently Asked Questions
Q: We would like to submit another “child” data package to be nested under a ... a new nested dataset, we strongly encourage...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found