Skip to content

Commit 028ea97

Browse files
committed
fix(tooltip): remove placement property
1 parent c386bdf commit 028ea97

File tree

15 files changed

+302
-418
lines changed

15 files changed

+302
-418
lines changed

CHANGELOG.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ All notable changes for each version of this project will be documented in this
1313
### New Features
1414

1515
- `IgxOverlay`
16-
- Position Settings now accept a new optional `placement` input property of type `Placement`. Controls where to place the element relative to the target element. Supported values are `top`, `top-start`, `top-end`, `bottom`, `bottom-start`, `bottom-end`, `right`, `right-start`, `right-end`, `left`, `left-start`, `left-end`.
17-
18-
_Note:_ `horizontalDirection`, `horizontalStartPoint`, `verticalDirection`, and `verticalStartPoint` has priority.
19-
20-
- Position Settings now accept a new optional `offset` input property of type `number`. Used to set the offset of the element from the target in pixels when shown in connected, elastic, or auto position strategy.
16+
- Position Settings now accept a new optional `offset` input property of type `number`. Used to set the offset of the element from the target in pixels.
2117

2218
- `IgxTooltip`
2319
- The tooltip now remains open while interacting with it.
@@ -36,32 +32,39 @@ All notable changes for each version of this project will be documented in this
3632

3733
- Introduced a new `hasArrow` input property. Controls whether to display an arrow indicator for the tooltip. Defaults to `false`.
3834

39-
_Note:_ The arrow's position takes `positionSettings.placement` property into account. If `hasArrow` is set to `true`, changing the `placement` property will change the arrow position as well.
40-
```html
41-
<igx-icon [igxTooltipTarget]="tooltipRef" [hasArrow]="true" [positionSettings]="settings">info</igx-icon>
42-
<span #tooltipRef="tooltip" igxTooltip>Hello there, I am a tooltip!</span>
43-
```
44-
```ts
45-
public settings: PositionSettings = {
46-
placement: Placement.TopStart
47-
}
48-
```
35+
_Note:_ The tooltip uses the `TooltipPositionStrategy` to position the tooltip and arrow element. If a custom position strategy is used (`overlaySettings.positionStrategy`) and `hasArrow` is set to `true`, the custom strategy should extend the `TooltipPositionStrategy`. Otherwise, the arrow will not be displayed.
36+
37+
_Note:_ The arrow element is positioned based on the provided position settings. If the directions and starting points do not correspond to any of the predefined position values, the arrow is positioned in the top middle side of the tooltip (default tooltip position `bottom`).
38+
39+
40+
| Position     | Horizontal Direction          | Horizontal Start Point         | Vertical Direction            | Vertical Start Point           |
41+
|--------------|-------------------------------|--------------------------------|-------------------------------|--------------------------------|
42+
| top          | HorizontalAlignment.Center    | HorizontalAlignment.Center     | VerticalAlignment.Top         | VerticalAlignment.Top          |
43+
| top-start    | HorizontalAlignment.Right     | HorizontalAlignment.Left       | VerticalAlignment.Top         | VerticalAlignment.Top          |
44+
| top-end      | HorizontalAlignment.Left      | HorizontalAlignment.Right      | VerticalAlignment.Top         | VerticalAlignment.Top          |
45+
| bottom       | HorizontalAlignment.Center    | HorizontalAlignment.Center     | VerticalAlignment.Bottom      | VerticalAlignment.Bottom       |
46+
| bottom-start | HorizontalAlignment.Right     | HorizontalAlignment.Left       | VerticalAlignment.Bottom      | VerticalAlignment.Bottom       |
47+
| bottom-end   | HorizontalAlignment.Left      | HorizontalAlignment.Right      | VerticalAlignment.Bottom      | VerticalAlignment.Bottom       |
48+
| right        | HorizontalAlignment.Right     | HorizontalAlignment.Right      | VerticalAlignment.Middle      | VerticalAlignment.Middle       |
49+
| right-start  | HorizontalAlignment.Right     | HorizontalAlignment.Right      | VerticalAlignment.Bottom      | VerticalAlignment.Top          |
50+
| right-end    | HorizontalAlignment.Right     | HorizontalAlignment.Right      | VerticalAlignment.Top         | VerticalAlignment.Bottom       |
51+
| left         | HorizontalAlignment.Left      | HorizontalAlignment.Left       | VerticalAlignment.Middle      | VerticalAlignment.Middle       |
52+
| left-start   | HorizontalAlignment.Left      | HorizontalAlignment.Left       | VerticalAlignment.Bottom      | VerticalAlignment.Top          |
53+
| left-end     | HorizontalAlignment.Left      | HorizontalAlignment.Left       | VerticalAlignment.Top         | VerticalAlignment.Bottom       |
54+
4955

50-
_Note:_ The tooltip uses the `TooltipPositionStrategy` to position the tooltip and arrow element. If a custom position strategy is used (`overlaySettings.positionStrategy`) and `hasArrow` is set to `true`, the custom strategy should implement the `ITooltipPositionStrategy` interface that exposes the `positionArrow(arrow: HTMLElement, arrowFit: ArrowFit)` method. Otherwise, the arrow will not be displayed.
5156

52-
_Note:_ The arrow element is positioned based on the `positionSettings.placement` property. If `horizontalDirection`, `horizontalStartPoint`, `verticalDirection`, and `verticalStartPoint` are used and the direction and starting point do not correspond to any of the predefined placement values, the arrow is positioned based on `Placement.Bottom` (top middle side of the tooltip).
53-
54-
The arrow can be positioned via a custom position strategy that implements the `positionArrow(arrow: HTMLElement, arrowFit: ArrowFit)` method.
57+
The arrow's position can be customized by overriding the `positionArrow(arrow: HTMLElement, arrowFit: ArrowFit)` method.
5558

5659
For example:
5760

5861
```ts
59-
export class CustomStrategy extends ConnectedPositioningStrategy implements ITooltipPositionStrategy {
62+
export class CustomStrategy extends TooltipPositioningStrategy {
6063
constructor(settings?: PositionSettings) {
6164
super(settings);
6265
}
6366

64-
public positionArrow(arrow: HTMLElement, arrowFit: ArrowFit): void {
67+
public override positionArrow(arrow: HTMLElement, arrowFit: ArrowFit): void {
6568
Object.assign(arrow.style, {
6669
left: '-0.25rem',
6770
transform: 'rotate(-45deg)',
@@ -72,7 +75,6 @@ All notable changes for each version of this project will be documented in this
7275

7376
public overlaySettings: OverlaySettings = {
7477
positionStrategy: new CustomStrategy({
75-
offset: 4,
7678
horizontalDirection: HorizontalAlignment.Right,
7779
horizontalStartPoint: HorizontalAlignment.Right,
7880
verticalDirection: VerticalAlignment.Bottom,

projects/igniteui-angular/src/lib/directives/tooltip/public_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { IgxTooltipDirective } from './tooltip.directive';
33

44
export * from './tooltip.directive';
55
export * from './tooltip-target.directive';
6-
export { TooltipPositionStrategy } from './tooltip.common';
6+
export { ArrowFit, TooltipPositionStrategy } from './tooltip.common';
77

88
/* NOTE: Tooltip directives collection for ease-of-use import in standalone components scenario */
99
export const IGX_TOOLTIP_DIRECTIVES = [

projects/igniteui-angular/src/lib/directives/tooltip/tooltip-target.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IgxToggleActionDirective } from '../toggle/toggle.directive';
1313
import { IgxTooltipComponent } from './tooltip.component';
1414
import { IgxTooltipDirective } from './tooltip.directive';
1515
import { IgxTooltipCloseButtonComponent } from './tooltip-close-button.component';
16-
import { TooltipPositionStrategy } from './tooltip.common';
16+
import { TooltipPositionSettings, TooltipPositionStrategy } from './tooltip.common';
1717

1818
export interface ITooltipShowEventArgs extends IBaseEventArgs {
1919
target: IgxTooltipTargetDirective;
@@ -329,7 +329,7 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen
329329
private _closeButtonRef?: ComponentRef<IgxTooltipCloseButtonComponent>;
330330
private _closeTemplate: TemplateRef<any>;
331331
private _sticky = false;
332-
private _positionSettings: PositionSettings;
332+
private _positionSettings: PositionSettings = TooltipPositionSettings;
333333

334334
constructor(
335335
private _element: ElementRef,

0 commit comments

Comments
 (0)