Skip to content

Commit 76f4323

Browse files
committed
refactor: update press implementation
1 parent a540083 commit 76f4323

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/user-event/press/press.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,19 @@ async function emitTextPressEvents(
118118
await wait(config);
119119
dispatchEvent(element, 'pressIn', EventBuilder.Common.touch());
120120

121-
// Emit either `press` or `longPress`.
122-
dispatchEvent(element, options.type, EventBuilder.Common.touch());
123-
124121
await wait(config, options.duration);
122+
123+
// Long press events are emitted before `pressOut`.
124+
if (options.type === 'longPress') {
125+
dispatchEvent(element, 'longPress', EventBuilder.Common.touch());
126+
}
127+
125128
dispatchEvent(element, 'pressOut', EventBuilder.Common.touch());
129+
130+
// Regular press events are emitted after `pressOut`.
131+
if (options.type === 'press') {
132+
dispatchEvent(element, 'press', EventBuilder.Common.touch());
133+
}
126134
}
127135

128136
/**

0 commit comments

Comments
 (0)