Skip to content

Commit 4962888

Browse files
Merge pull request #665 from universal-ember/copilot/update-docs-portal-clarity
Clarify Portal CSS selector support and PortalTargets defaults
2 parents c0bd30d + 9e692f1 commit 4962888

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

docs-app/app/templates/5-floaty-bits/portal-targets.gjs.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# PortalTargets
22

3-
The portal targets are stable element references that can be nested over and over again to get around layering issues.
3+
The portal targets are stable element references that can be nested over and over again to get around layering issues.
4+
5+
**`<PortalTargets />` renders three hardcoded default portal targets in the DOM:**
6+
- `popover` - for popover elements
7+
- `tooltip` - for tooltip elements
8+
- `modal` - for modal dialogs
9+
10+
These render as three `<div>` elements with `data-portal-name` attributes:
11+
```html
12+
<div data-portal-name="ember-primitives__portal-targets__popover"></div>
13+
<div data-portal-name="ember-primitives__portal-targets__tooltip"></div>
14+
<div data-portal-name="ember-primitives__portal-targets__modal"></div>
15+
```
16+
17+
You can reference these defaults by passing their names to `<Portal @to="popover">`, `<Portal @to="tooltip">`, or `<Portal @to="modal">`.
418

519
For example, given a z-index order like
620
- `1` popover

docs-app/app/templates/5-floaty-bits/portal.gjs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ A `<Portal>` allows teleporting elements to another place in the DOM tree. This
44

55
`<Portal>` must be combined with `<PortalTargets>`, or your own portal targets that match the requirements of portalling. Additionally, a `<Portal>` will render in to the nearest `<PortalTargets>` it can find, allowing for UI layering, e.g.: Modals have their own `<PortalTargets>` so they can have their own tooltips and popovers. _For use with popovers_, this portalling can be a way to support [popover](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover) on older browsers. But there are many other use cases outside of popovers as well.
66

7+
**The `@to` argument accepts any valid CSS selector** (like `[data-portal-target]`, `.my-class`, `#my-id`), a PortalTarget name (like `popover`, `tooltip`, or `modal`), or an Element object.
8+
79
<h2 visually-hidden>Usage</h2>
810

911
The following example demonstrates Portal-nesting:

0 commit comments

Comments
 (0)