Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

All notable changes for each version of this project will be documented in this file.

## 22.4.0

### New Functionality

- `IgxOverlayService`
- Overlays that use `ConnectedPositioningStrategy`, `AutoPositionStrategy` or `ContainerPositionStrategy` are positioned with native CSS anchor positioning in browsers that support it (Chrome, Edge, Firefox and Safari 26). The browser keeps the content attached to its target while the page scrolls or resizes, with no script running on scroll. Safari 18, subclasses of these strategies, `Point` targets, other strategies and start point/direction combinations such as `Left → Center` keep script positioning. See [Positioning engines](projects/igniteui-angular/core/src/services/overlay/README.md#positioning-engines).
- Added `HideScrollStrategy`, which hides the overlay content while its target is scrolled out of view and shows it again when the target returns. The overlay stays open.
```typescript
settings.scrollStrategy = new HideScrollStrategy();
```
- Added `provideOverlayAnchoring()`. Add `provideOverlayAnchoring('script')` to the application providers to keep script positioning for every overlay.
```typescript
bootstrapApplication(AppComponent, { providers: [provideOverlayAnchoring('script')] });
```

### General

- `IgxOverlayService`
- **Behavioral changes** with native anchor positioning. `provideOverlayAnchoring('script')` restores the previous behavior.
- Anchored content follows its target on scroll with every scroll strategy, including `NoOpScrollStrategy`. It follows one rendering frame after the scroll, so code that scrolls and measures in the same task sees the previous position.
- `AutoPositionStrategy` content also flips while the overlay is open, when the current side stops fitting. When no side fits, the browser shifts the content into the viewport; the exact position can differ from before.
- Positions are no longer rounded to whole pixels.
- While an overlay is open, its target has an inline `anchor-name` style.

### Bug Fixes

- `ContainerPositionStrategy` no longer throws from its `IntersectionObserver` after the overlay is detached (#16988).
- The Excel-style filtering submenu opens on the side the grid requests on every open, in browsers with native anchor positioning.

## 22.3.2

### General
Expand Down
42 changes: 41 additions & 1 deletion projects/igniteui-angular/core/src/services/overlay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,44 @@ A walk through of how to get started can be found [here](https://www.infragistic

- **Popover API Integration**: Uses the HTML Popover API for improved z-index management and automatic top-layer placement
- **Flexible Positioning**: Multiple position strategies (global, connected, auto, elastic, container)
- **Scroll Strategies**: Handle scroll behavior with NoOp, Block, Close, and Absolute strategies
- **Native Anchor Positioning**: Connected, auto and container overlays are positioned with CSS anchor positioning where the browser supports it, with no script running on scroll
- **Scroll Strategies**: Handle scroll behavior with NoOp, Block, Close, Absolute and Hide strategies
- **Modal Support**: Optional modal backdrop with configurable close-on-outside-click behavior
- **Animation Support**: Built-in support for open/close animations

## Positioning engines

Each time an overlay is shown, the service picks how to position it:

- **Native** - CSS anchor positioning, resolved by the browser in layout. The content stays attached to its target while the page scrolls or resizes, with every scroll strategy.
- **Script** - the position strategy measures the target and writes pixel offsets, as before 22.4.

An overlay uses the native engine when the browser supports CSS anchor positioning and one of these applies:

- The position strategy is exactly `ConnectedPositioningStrategy` or `AutoPositionStrategy` (not a subclass), the target is an `HTMLElement` in the document, in the same document or shadow root as the overlay, and each axis uses one of the pairs listed in the [position strategies README](position/README.md#native-anchor-positioning).
- The position strategy is exactly `ContainerPositionStrategy` and the overlay was attached with it.

Everything else uses the script engine: `GlobalPositionStrategy`, `ElasticPositionStrategy`, every subclass (for example tooltips), `Point` targets, and browsers without CSS anchor positioning (Safari 18). Chrome, Edge, Firefox and Safari 26 use the native engine.

Differences under the native engine:

- Anchored content follows its target on scroll with every scroll strategy, including `NoOpScrollStrategy`. It follows one rendering frame later than the script engine did, so code that scrolls and measures in the same task sees the previous position.
- `AutoPositionStrategy` content can flip while the overlay is open, not only when it is shown. When no side fits, the browser shifts it into the viewport; the exact position can differ from the script engine.
- `ConnectedPositioningStrategy` content never flips or shifts, as before.
- Positions are not rounded to whole pixels.
- While an overlay is open, its target has an inline `anchor-name` style. Values set by the application are kept.
- If the target is removed from the document while the overlay is open, the content loses its position.

To use the script engine for every overlay, add `provideOverlayAnchoring('script')` to the application providers. It takes effect only in the root environment injector:

```typescript
import { provideOverlayAnchoring } from 'igniteui-angular/core';

bootstrapApplication(AppComponent, {
providers: [provideOverlayAnchoring('script')]
});
```

## Usage

### With igxToggleDirective
Expand Down Expand Up @@ -138,6 +172,12 @@ this.overlay.show(component, overlaySettings);
|createAbsoluteOverlaySettings| Creates overlay settings with global or container position strategy based on a preset position settings |position?, useContainerStrategy?|
|createRelativeOverlaySettings| Creates overlay settings with auto, connected or elastic position strategy based on a preset position settings |target, strategy?, position?|

###### Providers

| Name | Description | Parameters |
|-----------------|---------------------------------------------------------------------------------|------------|
|provideOverlayAnchoring| Selects the positioning engine for every overlay: `'auto'` (default, native where supported) or `'script'`. Root providers only. See [Positioning engines](#positioning-engines). |mode|


##### Events

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
let counter = 0;

interface AnchorRecord {
/** Computed `anchor-name` before the element was touched, `''` for `none`. */
authorValue: string;
/** Inline `anchor-name` before the element was touched, `''` if none. */
inlineValue: string;
names: string[];
}

const records = new WeakMap<HTMLElement, AnchorRecord>();

/**
* @hidden @internal
* Returns a new, document-unique anchor name.
*/
export function acquireAnchorName(): string {
return `--igx-overlay-anchor-${counter++}`;
}

/**
* @hidden @internal
* Adds `name` to the element's `anchor-name` list, keeping any author value.
*/
export function addAnchorName(element: HTMLElement, name: string): void {
let record = records.get(element);
if (!record) {
const computed = element.ownerDocument.defaultView
?.getComputedStyle(element).getPropertyValue('anchor-name').trim() ?? '';
record = {
authorValue: computed === 'none' ? '' : computed,
inlineValue: element.style.getPropertyValue('anchor-name'),
names: []
};
records.set(element, record);
}
if (!record.names.includes(name)) {
record.names.push(name);
}
write(element, record);
}

/**
* @hidden @internal
* Removes `name` from the element's `anchor-name` list. Restores the author inline value when no names remain.
*/
export function removeAnchorName(element: HTMLElement, name: string): void {
const record = records.get(element);
if (!record) {
return;
}
record.names = record.names.filter(n => n !== name);
if (record.names.length) {
write(element, record);
return;
}
if (record.inlineValue) {
element.style.setProperty('anchor-name', record.inlineValue);
} else {
element.style.removeProperty('anchor-name');
}
records.delete(element);
}

function write(element: HTMLElement, record: AnchorRecord): void {
element.style.setProperty('anchor-name', [record.authorValue, ...record.names].filter(Boolean).join(', '));
}
Loading
Loading