Skip to content

feat(web): onImagePress#690

Open
hejsztynx wants to merge 4 commits into
@kacperzolkiewski/feat-on-image-pressfrom
@ksienkiewicz/feat-web-enriched-text-on-image-press
Open

feat(web): onImagePress#690
hejsztynx wants to merge 4 commits into
@kacperzolkiewski/feat-on-image-pressfrom
@ksienkiewicz/feat-web-enriched-text-on-image-press

Conversation

@hejsztynx

Copy link
Copy Markdown
Collaborator

Summary

Implemented onImagePress callback functionality on the web EnrichedText component

Test Plan

There is a set console.log callback in the main example app, to see the feature works.

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Web support for onImagePress on the EnrichedText renderer so consumers can react to inline image clicks (plus docs and an E2E test to validate behavior in the example web app).

Changes:

  • Added a Web click-interaction hook to emit onImagePress events from rendered HTML images.
  • Wired onImagePress into src/web/EnrichedText.tsx using a stable callback ref.
  • Updated docs + example web app, and added Playwright coverage for image press behavior (including list cases).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/web/usePressInteractions.ts New hook to detect image clicks and emit onImagePress.
src/web/EnrichedText.tsx Passes onImagePress into the interaction hook via useStableRef.
src/web/EnrichedText.css Adjusts checkbox-list pointer-events to allow clicks within list items while keeping checkbox non-interactive.
docs/WEB.md Documents that onImagePress is supported on Web.
docs/TEXT_API_REFERENCE.md Updates onImagePress platform support to include Web.
apps/example-web/src/testScreens/TestEnrichedText.tsx Captures and displays the last onImagePress event for E2E assertions.
apps/example-web/src/App.tsx Adds a console-log demo handler for onImagePress in the example app.
.playwright/tests/enrichedTextPress.spec.ts Adds Playwright E2E coverage for image press events (including list scenarios).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/web/EnrichedText.tsx
Comment on lines 16 to +17
import { usePressInteractions } from './usePressInteractions';
import { useStableRef } from './useStableRef';
Comment on lines +22 to +27
const handleInteraction = (e: MouseEvent) => {
const target = e.target as HTMLElement;

const image = target.closest('img');

if (image && container.contains(image)) {
Comment on lines +45 to +64
function parseImageAttributs(image: HTMLElement): ImageAttributes | undefined {
const uri = image.getAttribute('src');
const rawWidth = image.getAttribute('width');
const rawHeight = image.getAttribute('height');

if (uri && rawWidth && rawHeight) {
const width = parseInt(rawWidth, 10);
const height = parseInt(rawHeight, 10);

if (!isNaN(width) && !isNaN(height)) {
return {
uri,
width,
height,
};
}
}

return undefined;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants