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

adobe / spectrum-web-components / 14129001210

28 Mar 2025 12:32PM CUT coverage: 97.999% (-0.003%) from 98.002%
14129001210

Pull #5281

github

web-flow
Merge 92ee990b9 into fa4be70e9
Pull Request #5281: docs(button): updated button docs for accessibility

5324 of 5621 branches covered (94.72%)

Branch coverage included in aggregate %.

33709 of 34209 relevant lines covered (98.54%)

646.88 hits per line

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

83.33
/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.host.disabled) {
4!
24
            return;
×
25
        }
×
26
        if (this.preventNextToggle == 'no') {
4✔
27

4✔
28
            this.host.toggle();
4✔
29
        }
4✔
30
        this.preventNextToggle = 'no';
4✔
31
    }
4✔
32

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

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

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