Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/many-nails-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@lynx-js/web-constants": patch
"@lynx-js/web-elements": patch
---

fix: in lynx-view all-on-ui mode, the input event of input and textarea is triggered twice, and the first e.detail is a string, which does not conform to the expected data format.
3 changes: 3 additions & 0 deletions packages/web-platform/web-constants/src/eventName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const W3cEventNameToLynx: Record<string, string> = {
overlaytouch: 'touch',
lynxfocus: 'focus',
lynxblur: 'blur',
lynxinput: 'input',
};
export const LynxEventNameToW3cByTagName: Record<
string,
Expand All @@ -16,10 +17,12 @@ export const LynxEventNameToW3cByTagName: Record<
'X-INPUT': {
'blur': 'lynxblur',
'focus': 'lynxfocus',
'input': 'lynxinput',
},
'X-TEXTAREA': {
'blur': 'lynxblur',
'focus': 'lynxfocus',
'input': 'lynxinput',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class XInputEvents
);

@registerAttributeHandler('input-filter', true)
@registerEventEnableStatusChangeHandler('input')
@registerEventEnableStatusChangeHandler('lynxinput')
#handleEnableInputEvent(status: boolean | string | null) {
const input = this.#getInputElement();
if (status) {
Expand Down Expand Up @@ -83,7 +83,7 @@ export class XInputEvents
input.value = filterValue;
if (isComposing && !this.#sendComposingInput) return;
this.#dom.dispatchEvent(
new CustomEvent('input', {
new CustomEvent('lynxinput', {
...commonComponentEventSetting,
detail: {
value: filterValue,
Expand All @@ -109,7 +109,7 @@ export class XInputEvents
// if #sendComposingInput set true, #teleportInput will send detail
if (!this.#sendComposingInput) {
this.#dom.dispatchEvent(
new CustomEvent('input', {
new CustomEvent('lynxinput', {
...commonComponentEventSetting,
detail: {
value: filterValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class XTextareaEvents
);

@registerAttributeHandler('input-filter', true)
@registerEventEnableStatusChangeHandler('input')
@registerEventEnableStatusChangeHandler('lynxinput')
#handleEnableConfirmEvent(status: string | boolean | null) {
const textareaElement = this.#getTextareaElement();
if (status) {
Expand Down Expand Up @@ -83,7 +83,7 @@ export class XTextareaEvents
input.value = filterValue;
if (isComposing && !this.#sendComposingInput) return;
this.#dom.dispatchEvent(
new CustomEvent('input', {
new CustomEvent('lynxinput', {
...commonComponentEventSetting,
detail: {
value: filterValue,
Expand All @@ -109,7 +109,7 @@ export class XTextareaEvents
// if #sendComposingInput set true, #teleportInput will send detail
if (!this.#sendComposingInput) {
this.#dom.dispatchEvent(
new CustomEvent('input', {
new CustomEvent('lynxinput', {
...commonComponentEventSetting,
detail: {
value: filterValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ function App() {
const [result, setResult] = useState();

const onInput = ({ detail }) => {
if (typeof detail !== 'object') {
throw new Error(
`detail type not match. expect object, got ${typeof detail}`,
);
}

const { value, cursor, textLength, selectionStart, selectionEnd } = detail;

if (value.length !== textLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import './index.css';

function App() {
const onInput = (e) => {
if (typeof e.detail !== 'object') {
throw new Error(
`detail type not match. expect object, got ${typeof detail}`,
);
}
console.log(e);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
ReturnType<typeof expect<Page>>['toHaveScreenshot']
>[0],
) => {
await expect(page).toHaveScreenshot([`${caseName}`, `${subcaseName}.png`], {

Check failure on line 23 in packages/web-platform/web-tests/tests/web-elements.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright (Default) / check

[webkit] › tests/web-elements.spec.ts:251:5 › web-elements test suite › x-text › x-text/inline-truncation-with-inline-image

7) [webkit] › tests/web-elements.spec.ts:251:5 › web-elements test suite › x-text › x-text/inline-truncation-with-inline-image Error: expect(page).toHaveScreenshot(expected) 98 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-text/inline-truncation-with-inline-image/index-webkit-linux.png Received: /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/test-results/web-elements-web-elements--2cae5-runcation-with-inline-image-webkit/x-text/inline-truncation-with-inline-image/index-actual.png Diff: /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/test-results/web-elements-web-elements--2cae5-runcation-with-inline-image-webkit/x-text/inline-truncation-with-inline-image/index-diff.png Call log: - expect.toHaveScreenshot(x-text/inline-truncation-with-inline-image/index.png) with timeout 5000ms - verifying given screenshot expectation - taking page screenshot - waiting for fonts to load... - fonts loaded - 98 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - taking page screenshot - waiting for fonts to load... - fonts loaded - captured a stable screenshot - 98 pixels (ratio 0.01 of all image pixels) are different. 21 | >[0], 22 | ) => { > 23 | await expect(page).toHaveScreenshot([`${caseName}`, `${subcaseName}.png`], { | ^ 24 | maxDiffPixelRatio: 0, 25 | fullPage: true, 26 | animations: 'allow', at diffScreenShot (/home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/web-elements.spec.ts:23:22) at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/web-elements.spec.ts:255:13
maxDiffPixelRatio: 0,
fullPage: true,
animations: 'allow',
Expand Down Expand Up @@ -836,7 +836,7 @@
}, { title }) => {
await gotoWebComponentPage(page, title);
await wait(500);
expect(page.locator('x-foldview-slot-ng')).toHaveCSS('top', '200px');

Check failure on line 839 in packages/web-platform/web-tests/tests/web-elements.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright (Default) / check

[webkit] › tests/web-elements.spec.ts:833:5 › web-elements test suite › x-foldview-ng › x-foldview-ng/basic-toolbar-in-lynx-wrapper

8) [webkit] › tests/web-elements.spec.ts:833:5 › web-elements test suite › x-foldview-ng › x-foldview-ng/basic-toolbar-in-lynx-wrapper Error: expect(locator).toHaveCSS(expected) Locator: locator('x-foldview-slot-ng') Expected string: "200px" Received string: "" Call log: - expect.toHaveCSS with timeout 5000ms - waiting for locator('x-foldview-slot-ng') 837 | await gotoWebComponentPage(page, title); 838 | await wait(500); > 839 | expect(page.locator('x-foldview-slot-ng')).toHaveCSS('top', '200px'); | ^ 840 | }); 841 | test('x-foldview-ng/size-parent-grow-children-specific', async ({ 842 | page, at /home/runner/_work/lynx-stack/lynx-stack/packages/web-platform/web-tests/tests/web-elements.spec.ts:839:50
});
test('x-foldview-ng/size-parent-grow-children-specific', async ({
page,
Expand Down Expand Up @@ -2701,7 +2701,7 @@
.locator('#target')
.evaluateHandle((target) => {
let detail = { value: undefined };
target.addEventListener('input', (e) => {
target.addEventListener('lynxinput', (e) => {
detail.value = (e as any).detail.value;
});
return detail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<script src="/web-elements.js" defer></script>
<script type="module">
document.querySelector('x-textarea').addEventListener(
'input',
'lynxinput',
(e) => {
document.querySelector('.result').innerHTML = e.detail.value;
},
Expand Down
Loading