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

adobe / spectrum-web-components / 14094674923

26 Mar 2025 10:27PM CUT coverage: 86.218% (-11.8%) from 98.002%
14094674923

Pull #5221

github

web-flow
Merge 2a1ea92e7 into 3184c1e6a
Pull Request #5221: RFC | leverage css module imports in components

1737 of 2032 branches covered (85.48%)

Branch coverage included in aggregate %.

14184 of 16434 relevant lines covered (86.31%)

85.29 hits per line

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

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

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

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

1✔
18
export class ClickController extends InteractionController {
1✔
19
    override type = InteractionTypes.click;
×
20

×
21
    /**
×
22
     * An overlay with a `click` interaction should not close on click `triggerElement`.
×
23
     * When a click is initiated (`pointerdown`), apply `preventNextToggle` when the
×
24
     * overlay is `open` to prevent from toggling the overlay when the click event
×
25
     * propagates later in the interaction.
×
26
     */
×
27
    private preventNextToggle = false;
×
28

1✔
29
    handleClick(): void {
1✔
30
        if (!this.preventNextToggle) {
×
31
            this.open = !this.open;
×
32
        }
×
33
        this.preventNextToggle = false;
×
34
    }
×
35

1✔
36
    handlePointerdown(): void {
1✔
37
        this.preventNextToggle = this.open;
×
38
    }
×
39

1✔
40
    override init(): void {
1✔
41
        // Clean up listeners if they've already been bound
×
42
        this.abortController?.abort();
×
43
        this.abortController = new AbortController();
×
44
        const { signal } = this.abortController;
×
45
        this.target.addEventListener('click', () => this.handleClick(), {
×
46
            signal,
×
47
        });
×
48
        this.target.addEventListener(
×
49
            'pointerdown',
×
50
            () => this.handlePointerdown(),
×
51
            { signal }
×
52
        );
×
53
    }
×
54
}
1✔
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