-
Notifications
You must be signed in to change notification settings - Fork 55
feat(Input): expose Input's <input> element by inputRef #377
Conversation
Codecov Report
@@ Coverage Diff @@
## master #377 +/- ##
==========================================
+ Coverage 91.71% 91.72% +<.01%
==========================================
Files 41 41
Lines 1340 1341 +1
Branches 172 197 +25
==========================================
+ Hits 1229 1230 +1
Misses 107 107
Partials 4 4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
5c0b9a8
to
1617509
Compare
@@ -201,6 +205,12 @@ class Input extends AutoControlledComponent<Extendable<IInputProps>, IInputState | |||
}) | |||
} | |||
|
|||
private handleInputRef = (inputNode: HTMLElement) => { | |||
this.inputDomElement = inputNode as HTMLInputElement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also keep the naming convention of this.ref
for the root and this.*ref
for other slots. This then would be this.inputRef
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we're in some sort of contradiction here..
this used to be called this.inputRef
and was changed to this.inputDomElement
by me in #326 at @kuzhelov 's suggestion:
@kuzhelov @levithomason
can we get consensus and unblock @silviuavram ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the way it was being handled in Portal.tsx . There, the actual HTMLElement is called triggerNode/portalNode. So at the very best, this may be renamed to this.inputNode
. @Bugaa92 @kuzhelov what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally agree with @silviuavram's point - this variable definitely shouldn't be named as *Ref
, as it is not a ref. Consider the difference that is introduced by ref
semantics (taking React ref as an example):
const ref = ref
const element = ref ------ current -------> DOM element
vs
const element = DOM element
While ref
, as implied by its name, provides additional level of indirection for accessing DOM element, the object that is stored in the inputDomElement
variable is DOM element itself - thus, it definitely shouldn't be named as *ref
- more than that, the name that is currently used is quite precise in terms of reflecting what the value of this variable stays for.
Exposed the element through inputRef property of the Input component.