Preserved caption text on cancel of send files box.

This commit is contained in:
23rd
2026-04-22 10:21:54 +03:00
parent 876117bbf4
commit bfe2b8bc10
2 changed files with 12 additions and 5 deletions
+10 -4
View File
@@ -819,7 +819,7 @@ void SendFilesBox::prepare() {
setCloseByOutsideClick(false);
boxClosing() | rpl::on_next([=] {
if (!_confirmed && _cancelledCallback) {
if (!_confirmed && !_textTaken && _cancelledCallback) {
_cancelledCallback();
}
}, lifetime());
@@ -2251,10 +2251,16 @@ rpl::producer<TextWithTags> SendFilesBox::takeTextWithTagsRequests() const {
return _textWithTagsRequests.events();
}
void SendFilesBox::requestToTakeTextWithTags() const {
if (!_caption->isHidden()) {
_textWithTagsRequests.fire_copy(_caption->getTextWithTags());
void SendFilesBox::requestToTakeTextWithTags() {
if (_caption->isHidden()) {
return;
}
const auto text = _caption->getTextWithTags();
if (!_prefilledCaptionText.text.isEmpty() && text.text.isEmpty()) {
return;
}
_textTaken = true;
_textWithTagsRequests.fire_copy(text);
}
void SendFilesBox::setInnerFocus() {
+2 -1
View File
@@ -270,7 +270,7 @@ private:
void checkCharsLimitation();
void refreshMessagesCount();
void requestToTakeTextWithTags() const;
void requestToTakeTextWithTags();
bool validateLength(const QString &text) const;
[[nodiscard]] Fn<MenuDetails()> prepareSendMenuDetails(
@@ -303,6 +303,7 @@ private:
std::unique_ptr<Ui::RpWidget> _priceTag;
QImage _priceTagBg;
bool _confirmed = false;
bool _textTaken = false;
bool _invertCaption = false;
const object_ptr<Ui::InputField> _caption;