Skip to content

Commit 00037ef

Browse files
amiramdaniloff200
authored andcommitted
feat(popover): add delay option (#5389) (#5582)
* add delay option to popover * fix(popover): small fix in description
1 parent 93911f0 commit 00037ef

File tree

11 files changed

+150
-21
lines changed

11 files changed

+150
-21
lines changed

cypress/full/popover_page_spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,24 @@ describe('Popover demo page test suite', () => {
360360
popover.isPopoverDismiss(popoverContext);
361361
});
362362
});
363+
364+
describe('Popover with delay', () => {
365+
const delayPopover = popover.exampleDemosArr.delayPopover;
366+
it('when user clicks on "Popover with 0.5sec delay", then popover-container appear', () => {
367+
cy.viewport(1440, 900);
368+
popover.clickOnDemoMenu('Popover with delay');
369+
popover.clickOnBtn(delayPopover);
370+
popover.isPopoverAppears(delayPopover);
371+
popover.isPopoverVisible(delayPopover);
372+
});
373+
374+
it('when user clicks on "Popover with 0.5sec delay" again, then popover-container disappeared', () => {
375+
cy.viewport(1440, 900);
376+
popover.clickOnDemoMenu('Popover with delay');
377+
popover.clickOnBtn(delayPopover);
378+
popover.isPopoverAppears(delayPopover);
379+
popover.clickOnBtn(delayPopover);
380+
popover.isPopoverDismiss(delayPopover);
381+
});
382+
});
363383
});

cypress/support/popover.po.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export class PopoverPo extends BaseComponent {
2525
triggerIsOpen: 'demo-popover-trigger-by-isopen',
2626
componentLevelStyling: 'demo-popover-styling-local',
2727
customClass: 'demo-popover-class',
28-
popoverContext: 'demo-popover-context'
28+
popoverContext: 'demo-popover-context',
29+
delayPopover: 'demo-popover-delay'
2930
};
3031

3132
isPopoverPlacementCorrect(baseSelector: string, placement: string) {

demo/src/app/components/+popover/demos/config/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export function getPopoverConfig(): PopoverConfig {
77
return Object.assign(new PopoverConfig(), {
88
placement: 'right',
99
container: 'body',
10-
triggers: 'focus'
10+
triggers: 'focus',
11+
delay: 500
1112
});
1213
}
1314

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<button type="button" class="btn btn-primary"
2+
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." [delay]="500">
3+
Popover with 0.5sec delay
4+
</button>
5+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'demo-popover-delay',
5+
templateUrl: './delay.html'
6+
})
7+
export class DemoPopoverDelayComponent {}

demo/src/app/components/+popover/demos/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DemoPopoverConfigComponent } from './config/config';
66
import { DemoPopoverContainerComponent } from './container/container';
77
import { DemoPopoverContextComponent } from './popover-context/popover-context';
88
import { DemoPopoverCustomContentComponent } from './custom-content/custom-content';
9+
import { DemoPopoverDelayComponent } from './delay/delay';
910
import { DemoPopoverDismissComponent } from './dismiss/dismiss';
1011
import { DemoPopoverDynamicComponent } from './dynamic/dynamic';
1112
import { DemoPopoverDynamicHtmlComponent } from './dynamic-html/dynamic-html';
@@ -26,6 +27,7 @@ export const DEMO_COMPONENTS = [
2627
DemoPopoverContainerComponent,
2728
DemoPopoverContextComponent,
2829
DemoPopoverCustomContentComponent,
30+
DemoPopoverDelayComponent,
2931
DemoPopoverDismissComponent,
3032
DemoPopoverDynamicComponent,
3133
DemoPopoverDynamicHtmlComponent,

demo/src/app/components/+popover/popover-section.list.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { DemoPopoverConfigComponent } from './demos/config/config';
66
import { DemoPopoverContainerComponent } from './demos/container/container';
77
import { DemoPopoverContextComponent } from './demos/popover-context/popover-context';
88
import { DemoPopoverCustomContentComponent } from './demos/custom-content/custom-content';
9+
import { DemoPopoverDelayComponent } from './demos/delay/delay';
910
import { DemoPopoverDismissComponent } from './demos/dismiss/dismiss';
1011
import { DemoPopoverDynamicComponent } from './demos/dynamic/dynamic';
1112
import { DemoPopoverDynamicHtmlComponent } from './demos/dynamic-html/dynamic-html';
@@ -52,7 +53,7 @@ export const demoComponentContent: ContentSection[] = [
5253
anchor: 'placement',
5354
component: require('!!raw-loader!./demos/placement/placement.ts'),
5455
html: require('!!raw-loader!./demos/placement/placement.html'),
55-
description: `<p>Four positioning options are available: <code>top</code>, <code>right</code>,
56+
description: `<p>Four positioning options are available: <code>top</code>, <code>right</code>,
5657
<code>bottom</code>, and <code>left</code>.
5758
Besides that, <code>auto</code> option may be used to detect a position that fits the component on screen.</p>`,
5859
outlet: DemoPopoverPlacementComponent
@@ -177,6 +178,14 @@ export const demoComponentContent: ContentSection[] = [
177178
component: require('!!raw-loader!./demos/popover-context/popover-context.ts'),
178179
html: require('!!raw-loader!./demos/popover-context/popover-context.html'),
179180
outlet: DemoPopoverContextComponent
181+
},
182+
{
183+
title: 'Popover with delay',
184+
anchor: 'popover-delay',
185+
component: require('!!raw-loader!./demos/delay/delay.ts'),
186+
html: require('!!raw-loader!./demos/delay/delay.html'),
187+
description: `<p>Click on the button to see popover delayed for 0,5 second </p>`,
188+
outlet: DemoPopoverDelayComponent
180189
}
181190
]
182191
},

demo/src/ng-api-doc.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,12 @@ export const ngdoc: any = {
26242624
"defaultValue": "click",
26252625
"type": "string",
26262626
"description": "<p>Specifies events that should trigger. Supports a space separated list of\nevent names.</p>\n"
2627+
},
2628+
{
2629+
"name": "delay",
2630+
"defaultValue": "0",
2631+
"type": "number",
2632+
"description": "<p>delay before showing the popover</p>\n"
26272633
}
26282634
]
26292635
},
@@ -2649,6 +2655,11 @@ export const ngdoc: any = {
26492655
"type": "string",
26502656
"description": "<p>Css class for popover container</p>\n"
26512657
},
2658+
{
2659+
"name": "delay",
2660+
"type": "number",
2661+
"description": "<p>Delay before showing the popover</p>\n"
2662+
},
26522663
{
26532664
"name": "isOpen",
26542665
"type": "boolean",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
9.17: Popover with delay example
2+
==================================
3+
**Primary Actor**: User
4+
5+
**Scope**: Ngx-bootstrap DEMO / BS version 3&4
6+
7+
**Goal**:
8+
9+
Main success scenario:
10+
----------------------
11+
1. User opens Popover demo page
12+
2. User clicks on Popover with delay sub-menu
13+
3. User see button "Popover with 0.5sec delay"
14+
4. When user clicks on "Popover with 0.5sec delay", then popover-container appear above the button with 0.5sec delay
15+
5. When user clicks on "Popover with 0.5sec delay" again, then popover-container disappeared
16+
6. Template src should be written with [delay]="500"
17+
18+
Variations:
19+
-----------
20+
2*. User scroll to Popover with delay sub-menu

src/popover/popover.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ export class PopoverConfig {
2525
* A selector specifying the element the popover should be appended to.
2626
*/
2727
container: string;
28+
/** delay before showing the tooltip */
29+
delay = 0;
2830
}

0 commit comments

Comments
 (0)