DEV: Prevent possible Ember rendering error on Chat::DeleteChannel modal (#27248)

Under some circumstances, the TextField component could trigger a `Assertion Failed: You attempted to update attrs on ..., but it had already been used previously in the same computation...` error, causing the Ember app to crash.
This commit is contained in:
Sérgio Saquetim 2024-05-29 15:40:29 -03:00 committed by GitHub
parent 5a5086bbd7
commit d0ac6c33c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,12 +1,14 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { htmlSafe } from "@ember/template";
import { isEmpty } from "@ember/utils";
import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal";
import TextField from "discourse/components/text-field";
import withEventValue from "discourse/helpers/with-event-value";
import { popupAjaxError } from "discourse/lib/ajax-error";
import i18n from "discourse-common/helpers/i18n";
import discourseLater from "discourse-common/lib/later";
@ -83,13 +85,16 @@ export default class ChatModalDeleteChannel extends Component {
<p class="chat-modal-delete-channel__instructions">
{{this.instructionsText}}
</p>
<TextField
@value={{this.channelNameConfirmation}}
@id="channel-delete-confirm-name"
@placeholderKey="chat.channel_delete.confirm_channel_name"
@autocorrect="off"
@autocapitalize="off"
<input
{{on
"input"
(withEventValue (fn (mut this.channelNameConfirmation)))
}}
id="channel-delete-confirm-name"
placeholder={{i18n "chat.channel_delete.confirm_channel_name"}}
autocorrect="off"
autocapitalize="off"
type="text"
/>
</:body>
<:footer>