Skip to content

Commit bcf93d4

Browse files
fynnfeldpauschvalorkin
authored andcommitted
feat(tooltip): add delay to config (#4928)
closes #4029
1 parent bbad3df commit bcf93d4

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { TooltipConfig } from 'ngx-bootstrap/tooltip';
66
export function getAlertConfig(): TooltipConfig {
77
return Object.assign(new TooltipConfig(), {
88
placement: 'right',
9-
container: 'body'
9+
container: 'body',
10+
delay: 500
1011
});
1112
}
1213

demo/src/ng-api-doc.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ export const ngdoc: any = {
18741874
"properties": [
18751875
{
18761876
"name": "dropdownMenu",
1877-
"type": "Promise<BsComponentRef<any>>",
1877+
"type": "Promise<any>",
18781878
"description": "<p>Content to be displayed as popover.</p>\n"
18791879
}
18801880
]
@@ -3095,6 +3095,12 @@ export const ngdoc: any = {
30953095
"type": "string",
30963096
"description": "<p>a selector specifying the element the tooltip should be appended to. Currently only supports &quot;body&quot; </p>\n"
30973097
},
3098+
{
3099+
"name": "delay",
3100+
"defaultValue": "0",
3101+
"type": "number",
3102+
"description": "<p>delay before showing the tooltip </p>\n"
3103+
},
30983104
{
30993105
"name": "placement",
31003106
"defaultValue": "top",

docs/spec/tooltip/tooltip.examples.config-defaults.use-case.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Main success scenario:
1111
1. User opens Tooltip demo page
1212
2. User clicks on Configuring defaults sub-menu
1313
3. User see button "Preconfigured tooltip"
14-
4. When user hover on "Preconfigured tooltip", then tooltip-container shown on the right of button with specific text
14+
4. When user hover on "Preconfigured tooltip", then tooltip-container shown on the right of button with specific text after 500ms
1515
5. When user moves the mouse cursor away of tooltip-button, then tooltip-container disappeared
1616
6. Component src should be written with TooltipConfig and parameter: placement: "right"
1717

src/spec/ng-bootstrap/tooltip.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ describe('tooltip', () => {
523523
config.placement = 'bottom';
524524
config.triggers = 'click';
525525
config.container = 'body';
526+
config.delay = 500;
526527
})
527528
);
528529

@@ -534,6 +535,7 @@ describe('tooltip', () => {
534535
expect(tooltip.placement).toBe(config.placement);
535536
expect(tooltip.triggers).toBe(config.triggers);
536537
expect(tooltip.container).toBe(config.container);
538+
expect(tooltip.delay).toBe(config.delay);
537539
});
538540
});
539541

@@ -542,6 +544,7 @@ describe('tooltip', () => {
542544
config.placement = 'bottom';
543545
config.triggers = 'click';
544546
config.container = 'body';
547+
config.delay = 500;
545548

546549
beforeEach(() => {
547550
TestBed.configureTestingModule({
@@ -557,6 +560,7 @@ describe('tooltip', () => {
557560
expect(tooltip.placement).toBe(config.placement);
558561
expect(tooltip.triggers).toBe(config.triggers);
559562
expect(tooltip.container).toBe(config.container);
563+
expect(tooltip.delay).toBe(config.delay);
560564
});
561565
});
562566
});

src/tooltip/tooltip.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ export class TooltipConfig {
99
triggers = 'hover focus';
1010
/** a selector specifying the element the tooltip should be appended to. Currently only supports "body" */
1111
container: string;
12+
/** delay before showing the tooltip */
13+
delay = 0;
1214
}

0 commit comments

Comments
 (0)