Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Input): expose Input's <input> element by inputRef #377

Merged
merged 4 commits into from
Oct 24, 2018

Conversation

silviuaavram
Copy link
Collaborator

@silviuaavram silviuaavram commented Oct 19, 2018

Exposed the element through inputRef property of the Input component.

@silviuaavram silviuaavram changed the title Exposed Input Exposed Input's <input> element through inputRef Oct 19, 2018
@codecov
Copy link

codecov bot commented Oct 19, 2018

Codecov Report

Merging #377 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/components/Input/Input.tsx 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c96f8c0...88cdda1. Read the comment docs.

Copy link
Collaborator

@bmdalex bmdalex left a 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

@silviuaavram silviuaavram changed the title Exposed Input's <input> element through inputRef fix: Exposed Input's <input> element through inputRef Oct 22, 2018
@silviuaavram silviuaavram changed the title fix: Exposed Input's <input> element through inputRef fix: Exposed Input's <input> element through inputRef Oct 22, 2018
@silviuaavram silviuaavram changed the title fix: Exposed Input's <input> element through inputRef fix: exposed input element through inputRef Oct 22, 2018
@silviuaavram silviuaavram changed the title fix: exposed input element through inputRef fix: Exposed Input's <input> element through inputRef Oct 22, 2018
@@ -201,6 +205,12 @@ class Input extends AutoControlledComponent<Extendable<IInputProps>, IInputState
})
}

private handleInputRef = (inputNode: HTMLElement) => {
this.inputDomElement = inputNode as HTMLInputElement
Copy link
Member

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.

Copy link
Collaborator

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:
screen shot 2018-10-22 at 18 17 48

@kuzhelov @levithomason
can we get consensus and unblock @silviuavram ?

Copy link
Collaborator Author

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?

Copy link
Contributor

@kuzhelov kuzhelov Oct 23, 2018

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.

@levithomason levithomason added needs author changes Author needs to implement changes before merge and removed 🚀 ready for review labels Oct 22, 2018
@bmdalex bmdalex added the question Further information is requested, concerns that require additional thought are raised label Oct 22, 2018
@kuzhelov kuzhelov changed the title fix: Exposed Input's <input> element through inputRef feat(Input): expose Input's <input> element through inputRef Oct 24, 2018
@kuzhelov kuzhelov changed the title feat(Input): expose Input's <input> element through inputRef feat(Input): expose Input's <input> element by inputRef Oct 24, 2018
@kuzhelov kuzhelov removed the question Further information is requested, concerns that require additional thought are raised label Oct 24, 2018
@kuzhelov kuzhelov merged commit 556fef3 into master Oct 24, 2018
@layershifter layershifter deleted the fix/input-add-ref branch November 9, 2018 09:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants