Skip to content

fix: fix fake disappear event #1539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
5 changes: 5 additions & 0 deletions .changeset/modern-wombats-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/web-core": patch
---

fix: fake uidisappear event
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function createExposureMonitor(
if (isIntersecting && !exposedElements.has(target)) {
sendExposureEvent(target, true, target.getAttribute('exposure-id'));
exposedElements.add(target);
} else {
} else if (!isIntersecting && exposedElements.has(target)) {
sendExposureEvent(target, false, target.getAttribute('exposure-id'));
exposedElements.delete(target);
}
Expand Down
16 changes: 16 additions & 0 deletions packages/web-platform/web-tests/tests/react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,22 @@ test.describe('reactlynx3 tests', () => {
test.describe('api-exposure', () => {
const module = 'exposure';
test.fixme(isSSR, 'TODO: migrate exposure from web-elements to runtime');

test(
'api-exposure-no-fake-disappear',
async ({ page }, { title }) => {
await goto(page, title);
await wait(300);
await expect(page.locator('#control')).toHaveCSS(
'background-color',
'rgb(0, 128, 0)', // green
);
await expect(page.locator('#target')).toHaveCSS(
'background-color',
'rgb(0, 128, 0)', // green
);
},
);
test(
'api-exposure-area',
async ({ page }, { title }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2023 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { useState, root } from '@lynx-js/react';

function Page() {
const [appearTriggered, setAppearTriggered] = useState(false);
const [uidisappearTriggered, setUidisappearTriggered] = useState(false);

return (
<scroll-view style={{ height: '500px', width: '300px' }}>
<view
id='control'
style={{
width: '100%',
height: '550px',
background: appearTriggered ? 'green' : 'red',
}}
binduiappear={() => {
setAppearTriggered(true);
}}
>
</view>
<view
id='target'
style={{
width: '100%',
height: '50px',
background: uidisappearTriggered ? 'red' : 'green',
}}
binduidisappear={() => {
setUidisappearTriggered(true);
}}
binduiappear={() => {
setUidisappearTriggered(true);
}}
/>
</scroll-view>
);
}
root.render(<Page />);