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

adobe / spectrum-web-components / 13114709204

03 Feb 2025 01:34PM CUT coverage: 98.192% (+0.002%) from 98.19%
13114709204

Pull #5060

github

web-flow
Merge e11418a81 into 9dcf7fefc
Pull Request #5060: fix(picker): stop the click events from reaching the elements below picker-tray

5188 of 5464 branches covered (94.95%)

Branch coverage included in aggregate %.

36 of 36 new or added lines in 2 files covered. (100.0%)

33099 of 33528 relevant lines covered (98.72%)

381.19 hits per line

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

86.08
/packages/picker/src/MobileController.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
Unless required by applicable law or agreed to in writing, software distributed under
30✔
7
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30✔
8
OF ANY KIND, either express or implied. See the License for the specific language
30✔
9
governing permissions and limitations under the License.
30✔
10
*/
30✔
11

30✔
12
import {
30✔
13
    InteractionController,
30✔
14
    InteractionTypes,
30✔
15
    SAFARI_FOCUS_RING_CLASS,
30✔
16
} from './InteractionController.js';
30✔
17
import { isWebKit } from '@spectrum-web-components/shared';
30✔
18

30✔
19
export class MobileController extends InteractionController {
30✔
20
    override type = InteractionTypes.mobile;
4✔
21

30✔
22
    handleClick(): void {
30✔
23
        if (this.preventNextToggle == 'no') {
4✔
24
            this.open = !this.open;
4✔
25
        }
4✔
26
        this.preventNextToggle = 'no';
4✔
27
    }
4✔
28

30✔
29
    public override handlePointerdown(): void {
30✔
30
        this.preventNextToggle = this.open ? 'yes' : 'no';
4!
31
        if (isWebKit()) {
4!
32
            this.target.classList.add(SAFARI_FOCUS_RING_CLASS);
×
33
        }
×
34
    }
4✔
35

30✔
36
    private handleFocusOut(): void {
30✔
37
        if (this.host.open) {
4✔
38
            return;
4✔
39
        }
4!
40
        if (
×
41
            isWebKit() &&
×
42
            this.target.classList.contains(SAFARI_FOCUS_RING_CLASS)
×
43
        ) {
4!
44
            this.target.classList.remove(SAFARI_FOCUS_RING_CLASS);
×
45
        }
×
46
    }
4✔
47

30✔
48
    override init(): void {
30✔
49
        // Clean up listeners if they've already been bound
8✔
50
        this.abortController?.abort();
8✔
51
        this.abortController = new AbortController();
8✔
52
        const { signal } = this.abortController;
8✔
53
        this.target.addEventListener('click', () => this.handleClick(), {
8✔
54
            signal,
8✔
55
        });
8✔
56
        this.target.addEventListener(
8✔
57
            'pointerdown',
8✔
58
            () => this.handlePointerdown(),
8✔
59
            { signal }
8✔
60
        );
8✔
61
        this.target.addEventListener('focusout', () => this.handleFocusOut(), {
8✔
62
            signal,
8✔
63
        });
8✔
64
    }
8✔
65
}
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