Skip to content

Commit f8bdf91

Browse files
committed
fix(ui-view,ui-buttons): clarify typing of elementRefs
INSTUI-4696
1 parent fd4f7b9 commit f8bdf91

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

packages/ui-buttons/src/BaseButton/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class BaseButton extends Component<BaseButtonProps> {
7676
cursor: 'pointer'
7777
} as const
7878

79-
ref: Element | null = null
79+
ref: HTMLElement | null = null
8080

8181
componentDidMount() {
8282
this.props.makeStyles?.(this.makeStylesVariables)
@@ -143,10 +143,10 @@ class BaseButton extends Component<BaseButtonProps> {
143143
}
144144

145145
focus() {
146-
this.ref && (this.ref as HTMLElement).focus()
146+
this.ref && this.ref.focus()
147147
}
148148

149-
handleElementRef = (el: Element | null) => {
149+
handleElementRef = (el: HTMLElement | null) => {
150150
const { elementRef } = this.props
151151

152152
this.ref = el

packages/ui-buttons/src/BaseButton/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type BaseButtonOwnProps = {
6161
/**
6262
* Provides a reference to the `Button`'s underlying html element.
6363
*/
64-
elementRef?: (element: Element | null) => void
64+
elementRef?: (element: HTMLElement | null) => void
6565

6666
/**
6767
* The element to render as the component root, `Button` by default.

packages/ui-view/src/View/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class View extends Component<ViewProps> {
185185

186186
ref: Element | null = null
187187

188-
handleElementRef = (el: Element | null) => {
188+
handleElementRef = (el: HTMLElement | null) => {
189189
if (typeof this.props.elementRef === 'function') {
190190
this.props.elementRef(el)
191191
}

packages/ui-view/src/View/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type ViewOwnProps = {
6767
/**
6868
* provides a reference to the underlying html element
6969
*/
70-
elementRef?: (element: Element | null) => void
70+
elementRef?: (element: HTMLElement | null) => void
7171
/**
7272
* By default the display prop is 'auto', meaning it takes on the
7373
* display rules of the html element it's rendered as (see `as` prop).

0 commit comments

Comments
 (0)