• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

adobe / spectrum-web-components / 14134704076

28 Mar 2025 05:38PM CUT coverage: 98.002%. Remained the same
14134704076

Pull #5277

github

web-flow
Merge dc33d918c into 54e4c93de
Pull Request #5277: chore: update dependency @spectrum-css/breadcrumb to v10.0.1

5326 of 5622 branches covered (94.73%)

Branch coverage included in aggregate %.

33711 of 34211 relevant lines covered (98.54%)

646.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.83
/packages/picker/src/DesktopController.ts
1
/*
30✔
2
Copyright 2024 Adobe. All rights reserved.
30✔
3
This file is licensed to you under the Apache License, Version 2.0 (the "License");
30✔
4
you may not use this file except in compliance with the License. You may obtain a copy
30✔
5
of the License at http://www.apache.org/licenses/LICENSE-2.0
30✔
6

30✔
7
Unless required by applicable law or agreed to in writing, software distributed under
30✔
8
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30✔
9
OF ANY KIND, either express or implied. See the License for the specific language
30✔
10
governing permissions and limitations under the License.
30✔
11
*/
30✔
12

30✔
13
import {
30✔
14
    InteractionController,
30✔
15
    InteractionTypes,
30✔
16
} from './InteractionController.js';
30✔
17

30✔
18
export class DesktopController extends InteractionController {
30✔
19
    override type = InteractionTypes.desktop;
465✔
20

30✔
21
    public override handlePointerdown(event: PointerEvent): void {
30✔
22
        if (event.button !== 0 || event.pointerType === 'touch') {
21!
23
            return;
×
24
        }
×
25
        this.pointerdownState = this.open;
21✔
26
        this.preventNextToggle = 'maybe';
21✔
27
        let cleanupAction = 0;
21✔
28
        const cleanup = (): void => {
21✔
29
            cancelAnimationFrame(cleanupAction);
38✔
30
            cleanupAction = requestAnimationFrame(async () => {
38✔
31
                document.removeEventListener('pointerup', cleanup);
21✔
32
                document.removeEventListener('pointercancel', cleanup);
21✔
33
                this.target.removeEventListener('click', cleanup);
21✔
34
                requestAnimationFrame(() => {
21✔
35
                    // Complete cleanup on the second animation frame so that `click` can go first.
21✔
36
                    this.preventNextToggle = 'no';
21✔
37
                });
21✔
38
            });
38✔
39
        };
38✔
40
        // Ensure that however the pointer goes up we do `cleanup()`.
21✔
41
        document.addEventListener('pointerup', cleanup);
21✔
42
        document.addEventListener('pointercancel', cleanup);
21✔
43
        this.target.addEventListener('click', cleanup);
21✔
44
        this.handleActivate();
21✔
45
    }
21✔
46

30✔
47
    public override handleActivate(event?: Event): void {
30✔
48
        if (this.enterKeydownOn && this.enterKeydownOn !== this.target) {
38!
49
            return;
×
50
        }
×
51
        if (this.preventNextToggle === 'yes') {
38!
52
            return;
×
53
        }
×
54
        if (event?.type === 'click' && this.open !== this.pointerdownState) {
38✔
55
            // When activation comes from a `click` event ensure that the `pointerup`
17✔
56
            // event didn't already toggle the Picker state before doing so.
17✔
57
            return;
17✔
58
        }
17✔
59
        this.host.toggle();
21✔
60
    }
38✔
61

30✔
62
    override init(): void {
30✔
63
        // Clean up listeners if they've already been bound
936✔
64
        this.abortController?.abort();
936✔
65
        this.abortController = new AbortController();
936✔
66
        const { signal } = this.abortController;
936✔
67
        this.target.addEventListener(
936✔
68
            'click',
936✔
69
            (event: Event) => this.handleActivate(event),
936✔
70
            {
936✔
71
                signal,
936✔
72
            }
936✔
73
        );
936✔
74
        this.target.addEventListener(
936✔
75
            'pointerdown',
936✔
76
            (event: PointerEvent) => this.handlePointerdown(event),
936✔
77
            { signal }
936✔
78
        );
936✔
79
        this.target.addEventListener(
936✔
80
            'focus',
936✔
81
            (event: FocusEvent) => this.handleButtonFocus(event),
936✔
82
            {
936✔
83
                signal,
936✔
84
            }
936✔
85
        );
936✔
86
    }
936✔
87
}
30✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc