fix: Correctly determine holdsState in onlyTime mode to prevent result removal #7821
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧠 Problem Summary
In
only="time"
mode, the original logic of theholdsState()
method was:During the first time selecting a time:
self.time
is assigned;updateResult()
triggerscreatePerObjectResult()
, successfully creating the result.However, during the second time modifying the time:
self.time
is assigned;updateResult()
triggersself.result.area.setValue(self);
tag.holdsState
is evaluated to determine whether to keep the result;!isDefined(self.time)
isfalse
, it falls through toreturn isDefined(self.month) || isDefined(self.year)
;only="time"
mode,month
andyear
are alwaysundefined
, soholdsState
returnsfalse
;removeResult(result)
, removing the result, causing the bug where the input disappears after being set.Changing the value again after that is just repeating this process.This behavior leads to an incorrect state evaluation that breaks expected functionality.
The involved files include: DateTime.jsx, ClassificationBase.js, AreaMixin.js
Description:
In
only="time"
mode, the previous logic ofholdsState()
caused a regression where time updates would be discarded unexpectedly. The original condition:would fall through to checking
month
andyear
, which are always undefined inonly="time"
mode, leading to an incorrectfalse
return value. This resulted in the result being removed during subsequent time changes.This change simplifies and corrects the logic:
Now, in
only="time"
mode, the state is solely determined by whetherself.time
is defined — aligning with the intended behavior and preventing unintended result removal.🔍Problem Solved:
only="time"
Parameter Fails to Display Selected Value #7628before:
after:
📁 Changed Files
Path:
libs/editor/src/tags/control/DateTime.jsx
Code Changes:
✅ Testing Recommendation:
only="time"
mode.