Skip to content

Commit

Permalink
Fix ignored initial value of TextInput
Browse files Browse the repository at this point in the history
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D19922731

fbshipit-source-id: b06f1d98d97a4ea46c60e07a89452ee77acded8d
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Feb 19, 2020
1 parent 0e4bcaa commit 145151e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ namespace react {
extern char const TextInputComponentName[] = "TextInput";

AttributedStringBox TextInputShadowNode::attributedStringBoxToMeasure() const {
bool hasMeaningfulState = getState() && getState()->getRevision() != 0;
bool hasMeaningfulState =
getState() && getState()->getRevision() != State::initialRevisionValue;

if (hasMeaningfulState) {
auto attributedStringBox = getStateData().attributedStringBox;
Expand Down Expand Up @@ -66,7 +67,7 @@ void TextInputShadowNode::setTextLayoutManager(
void TextInputShadowNode::updateStateIfNeeded() {
ensureUnsealed();

if (!getState() || getState()->getRevision() == 0) {
if (!getState() || getState()->getRevision() == State::initialRevisionValue) {
auto state = TextInputState{};
state.attributedStringBox = AttributedStringBox{getAttributedString()};
state.paragraphAttributes = getConcreteProps().paragraphAttributes;
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/fabric/core/state/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ State::State(StateData::Shared const &data, State const &state)
State::State(
StateData::Shared const &data,
ShadowNodeFamily::Shared const &family)
: family_(family), data_(data), revision_{1} {};
: family_(family), data_(data), revision_{State::initialRevisionValue} {};

State::Shared State::getMostRecentState() const {
auto family = family_.lock();
Expand Down
2 changes: 2 additions & 0 deletions ReactCommon/fabric/core/state/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class State {
public:
using Shared = std::shared_ptr<const State>;

static size_t constexpr initialRevisionValue = 1;

protected:
/*
* Constructors are protected to make calling them directly with
Expand Down

0 comments on commit 145151e

Please sign in to comment.