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

adobe / spectrum-web-components / 12802187570

16 Jan 2025 04:36AM CUT coverage: 98.206% (-0.003%) from 98.209%
12802187570

Pull #5019

github

web-flow
Merge 012b0d7d4 into cee6892e5
Pull Request #5019: chore: fix update-spectrum-css script

5151 of 5424 branches covered (94.97%)

Branch coverage included in aggregate %.

33006 of 33430 relevant lines covered (98.73%)

380.51 hits per line

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

86.25
/packages/picker/src/MobileController.ts
1
/*
29✔
2
Copyright 2024 Adobe. All rights reserved.
29✔
3
This file is licensed to you under the Apache License, Version 2.0 (the "License");
29✔
4
you may not use this file except in compliance with the License. You may obtain a copy
29✔
5
of the License at http://www.apache.org/licenses/LICENSE-2.0
29✔
6
Unless required by applicable law or agreed to in writing, software distributed under
29✔
7
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
29✔
8
OF ANY KIND, either express or implied. See the License for the specific language
29✔
9
governing permissions and limitations under the License.
29✔
10
*/
29✔
11

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

29✔
18
export const SAFARI_FOCUS_RING_CLASS = 'remove-focus-ring-safari-hack';
29✔
19

29✔
20
export class MobileController extends InteractionController {
29✔
21
    override type = InteractionTypes.mobile;
1✔
22

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

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

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

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