Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions packages/picker/src/InteractionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,6 @@ export class InteractionController implements ReactiveController {

hostConnected(): void {
this.init();
this.host.addEventListener('sp-opened', () => {
/**
* set shouldSupportDragAndSelect to false for mobile
* to prevent click event being captured behind the menu-tray
* we do this here because the menu gets reinitialized on overlay open
*/
this.host.optionsMenu.shouldSupportDragAndSelect =
!this.host.isMobile.matches;
});
this.host.addEventListener('sp-closed', () => {
if (
!this.open &&
Expand Down
3 changes: 3 additions & 0 deletions packages/picker/src/Picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type { SlottableRequestEvent } from '@spectrum-web-components/overlay/src
import { DependencyManagerController } from '@spectrum-web-components/reactive-controllers/src/DependencyManger.js';
import {
IS_MOBILE,
IS_TOUCH_DEVICE,
MatchMediaController,
} from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
import type { Tooltip } from '@spectrum-web-components/tooltip';
Expand Down Expand Up @@ -84,6 +85,7 @@ export class PickerBase extends SizedMixin(SpectrumElement, {
};

public isMobile = new MatchMediaController(this, IS_MOBILE);
public isTouchDevice = new MatchMediaController(this, IS_TOUCH_DEVICE);

public strategy!: DesktopController | MobileController;

Expand Down Expand Up @@ -772,6 +774,7 @@ export class PickerBase extends SizedMixin(SpectrumElement, {
role=${this.listRole}
.selects=${this.selects}
.selected=${this.value ? [this.value] : []}
.shouldSupportDragAndSelect=${!this.isTouchDevice.matches}
size=${this.size}
@sp-menu-item-keydown=${this.handleEscape}
@sp-menu-item-added-or-updated=${this.shouldManageSelection}
Expand Down
1 change: 1 addition & 0 deletions tools/reactive-controllers/src/MatchMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { ReactiveController, ReactiveElement } from 'lit';
export const DARK_MODE = '(prefers-color-scheme: dark)';
export const IS_MOBILE =
'(max-width: 743px) and (hover: none) and (pointer: coarse)';
export const IS_TOUCH_DEVICE = '(hover: none) and (pointer: coarse)';

export class MatchMediaController implements ReactiveController {
key = Symbol('match-media-key');
Expand Down
Loading