diff --git a/driver/js/packages/global.d.ts b/driver/js/packages/global.d.ts index 169bf5551ee..673bb1e29d7 100644 --- a/driver/js/packages/global.d.ts +++ b/driver/js/packages/global.d.ts @@ -21,6 +21,12 @@ declare namespace HippyTypes { export type __PLATFORM__ = 'ios' | 'android' | null; + export interface Event { + type: string; + bubbles: boolean; + currentTarget: Element | null; + target: Element | null; + } export interface TouchEvent { // Touch coordinate X @@ -31,6 +37,12 @@ declare namespace HippyTypes { page_y: number; } + + export interface ClickEvent extends Event { + eventPhase: EventPhase; + [key: string]: any; + } + export interface FocusEvent { // Focus status focus: boolean; diff --git a/driver/js/packages/hippy-react/src/components/focusable.tsx b/driver/js/packages/hippy-react/src/components/focusable.tsx index 0e9a007ff83..99c9a52d1f7 100644 --- a/driver/js/packages/hippy-react/src/components/focusable.tsx +++ b/driver/js/packages/hippy-react/src/components/focusable.tsx @@ -32,7 +32,7 @@ interface FocusableProps { nextFocusUpId?: string; nextFocusLeftId?: string; nextFocusRightId?: string; - onClick?: () => void; + onClick?: (evt: HippyTypes.ClickEvent) => void; onFocus?: (evt: HippyTypes.FocusEvent) => void; } diff --git a/driver/js/packages/hippy-react/src/event/event.ts b/driver/js/packages/hippy-react/src/event/event.ts index a686db27cae..c240885c7ec 100644 --- a/driver/js/packages/hippy-react/src/event/event.ts +++ b/driver/js/packages/hippy-react/src/event/event.ts @@ -18,14 +18,13 @@ * limitations under the License. */ -interface Event { - type: string; - bubbles: boolean; - currentTarget: Element | null; - target: Element | null; -} -class Event implements Event { +class Event implements HippyTypes.Event { + public type: string; + public bubbles: boolean; + public currentTarget: Element | null; + public target: Element | null; + /** * constructor * @param eventName - handler name, e.g. onClick diff --git a/driver/js/packages/hippy-react/src/types/index.ts b/driver/js/packages/hippy-react/src/types/index.ts index 904cd077874..7486cc79dc9 100644 --- a/driver/js/packages/hippy-react/src/types/index.ts +++ b/driver/js/packages/hippy-react/src/types/index.ts @@ -61,7 +61,7 @@ export interface ClickableProps { /** * Called when the touch is released. */ - onClick?: () => void; + onClick?: (evt: HippyTypes.ClickEvent) => void; /** * Called when the touch with longer than about 1s is released.