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

adobe / spectrum-web-components / 10714988708

05 Sep 2024 06:20AM UTC coverage: 98.192% (-0.008%) from 98.2%
10714988708

Pull #4724

github

web-flow
Merge 8c1dfeb6d into c76f3f54f
Pull Request #4724: fix(picker): do not force focus visible on click in safari

5182 of 5443 branches covered (95.2%)

Branch coverage included in aggregate %.

9 of 11 new or added lines in 1 file covered. (81.82%)

32519 of 32952 relevant lines covered (98.69%)

381.71 hits per line

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

93.42
/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 class MobileController extends InteractionController {
29✔
19
    override type = InteractionTypes.mobile;
1✔
20

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

29✔
28
    public override handlePointerdown(): void {
29✔
29
        this.preventNextToggle = this.open ? 'yes' : 'no';
1!
30
    }
1✔
31

29✔
32
    public override handleButtonFocus(event: FocusEvent): void {
29✔
33
        super.handleButtonFocus(event);
1✔
34

1✔
35
        // if the focus comes from a closing the menu, we need to make sure to
1✔
36
        // unset the :focus-visible state to avoid the focus ring on safari mobile
1✔
37
        if (isWebKit() && !this.open) {
1!
NEW
38
            this.target.blur();
×
NEW
39
        }
×
40
    }
1✔
41

29✔
42
    override init(): void {
29✔
43
        // Clean up listeners if they've already been bound
2✔
44
        this.abortController?.abort();
2✔
45
        this.abortController = new AbortController();
2✔
46
        const { signal } = this.abortController;
2✔
47
        this.target.addEventListener('click', () => this.handleClick(), {
2✔
48
            signal,
2✔
49
        });
2✔
50
        this.target.addEventListener(
2✔
51
            'pointerdown',
2✔
52
            () => this.handlePointerdown(),
2✔
53
            { signal }
2✔
54
        );
2✔
55
        this.target.addEventListener(
2✔
56
            'focus',
2✔
57
            (event: FocusEvent) => this.handleButtonFocus(event),
2✔
58
            {
2✔
59
                signal,
2✔
60
            }
2✔
61
        );
2✔
62
    }
2✔
63
}
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