Skip to content

Commit

Permalink
feat(positioning): position tooltip and popover automatically (#3019)
Browse files Browse the repository at this point in the history
The preference always goes to the 'top', but if it doesn't fit, the popup will be positioned automatically
  • Loading branch information
fbasso authored and maxokorokov committed Feb 13, 2019
1 parent 7f670ed commit aeb39aa
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/popover/popover-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('ngb-popover-config', () => {
const config = new NgbPopoverConfig();

expect(config.autoClose).toBe(true);
expect(config.placement).toBe('top');
expect(config.placement).toBe('auto');
expect(config.triggers).toBe('click');
expect(config.container).toBeUndefined();
expect(config.disablePopover).toBe(false);
Expand Down
2 changes: 1 addition & 1 deletion src/popover/popover-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {PlacementArray} from '../util/positioning';
@Injectable({providedIn: 'root'})
export class NgbPopoverConfig {
autoClose: boolean | 'inside' | 'outside' = true;
placement: PlacementArray = 'top';
placement: PlacementArray = 'auto';
triggers = 'click';
container: string;
disablePopover = false;
Expand Down
4 changes: 2 additions & 2 deletions src/popover/popover.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('ngb-popover', () => {
const windowEl = getWindow(fixture.nativeElement);

expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass(`bs-popover-${defaultConfig.placement}`);
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl.textContent.trim()).toBe('TitleHello, World!');
expect(windowEl.getAttribute('role')).toBe('tooltip');
expect(windowEl.getAttribute('id')).toBe('ngb-popover-1');
Expand All @@ -133,7 +133,7 @@ describe('ngb-popover', () => {
const windowEl = getWindow(fixture.nativeElement);

expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass(`bs-popover-${defaultConfig.placement}`);
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl.textContent.trim()).toBe('TitleHello, John!');
expect(windowEl.getAttribute('role')).toBe('tooltip');
expect(windowEl.getAttribute('id')).toBe('ngb-popover-2');
Expand Down
2 changes: 1 addition & 1 deletion src/tooltip/tooltip-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('ngb-tooltip-config', () => {
const config = new NgbTooltipConfig();

expect(config.autoClose).toBe(true);
expect(config.placement).toBe('top');
expect(config.placement).toBe('auto');
expect(config.triggers).toBe('hover');
expect(config.container).toBeUndefined();
expect(config.disableTooltip).toBe(false);
Expand Down
2 changes: 1 addition & 1 deletion src/tooltip/tooltip-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {PlacementArray} from '../util/positioning';
@Injectable({providedIn: 'root'})
export class NgbTooltipConfig {
autoClose: boolean | 'inside' | 'outside' = true;
placement: PlacementArray = 'top';
placement: PlacementArray = 'auto';
triggers = 'hover';
container: string;
disableTooltip = false;
Expand Down
2 changes: 1 addition & 1 deletion src/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('ngb-tooltip', () => {
const windowEl = getWindow(fixture.nativeElement);

expect(windowEl).toHaveCssClass('tooltip');
expect(windowEl).toHaveCssClass(`bs-tooltip-${defaultConfig.placement}`);
expect(windowEl).toHaveCssClass('bs-tooltip-top');
expect(windowEl.textContent.trim()).toBe('Great tip!');
expect(windowEl.getAttribute('role')).toBe('tooltip');
expect(windowEl.getAttribute('id')).toBe('ngb-tooltip-0');
Expand Down

0 comments on commit aeb39aa

Please sign in to comment.