Skip to content

Commit 57e192b

Browse files
committed
move toward input edit
1 parent 5a3eba8 commit 57e192b

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

app/assets/javascripts/discourse/app/controllers/topic.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { service } from "@ember/service";
88
import { isEmpty, isPresent } from "@ember/utils";
99
import { observes } from "@ember-decorators/object";
1010
import BufferedProxy from "ember-buffered-proxy/proxy";
11+
import { log } from "qunit";
1112
import { Promise } from "rsvp";
1213
import {
1314
CLOSE_INITIATED_BY_BUTTON,
@@ -374,6 +375,15 @@ export default class TopicController extends Controller {
374375
}
375376
}
376377

378+
@action
379+
autoResize(event) {
380+
const textArea = event.target;
381+
const scrollHeight = textArea.scrollHeight;
382+
383+
textArea.style.height = "auto";
384+
textArea.style.height = scrollHeight + "px";
385+
}
386+
377387
@action
378388
jumpTop(event) {
379389
if (event && wantsNewWindow(event)) {

app/assets/javascripts/discourse/app/templates/topic.gjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Textarea } from "@ember/component";
12
import { array, concat, fn, hash } from "@ember/helper";
23
import { on } from "@ember/modifier";
34
import { getProperties } from "@ember/object";
@@ -23,7 +24,6 @@ import SelectedPosts from "discourse/components/selected-posts";
2324
import SharedDraftControls from "discourse/components/shared-draft-controls";
2425
import SignupCta from "discourse/components/signup-cta";
2526
import SlowModeInfo from "discourse/components/slow-mode-info";
26-
import TextField from "discourse/components/text-field";
2727
import TopicAdminMenu from "discourse/components/topic-admin-menu";
2828
import TopicCategory from "discourse/components/topic-category";
2929
import TopicFooterButtons from "discourse/components/topic-footer-buttons";
@@ -120,11 +120,14 @@ export default RouteTemplate(
120120
buffered=@controller.buffered
121121
}}
122122
>
123-
<TextField
123+
<Textarea
124124
@id="edit-title"
125125
@value={{@controller.buffered.title}}
126126
@maxlength={{@controller.siteSettings.max_topic_title_length}}
127-
@autofocus="true"
127+
autofocus="true"
128+
id="edit-title"
129+
{{on "input" @controller.autoResize}}
130+
{{on "focusin" @controller.autoResize}}
128131
/>
129132
</PluginOutlet>
130133
</div>

app/assets/stylesheets/common/base/topic.scss

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@
192192
outline: 2px solid transparent;
193193
border-radius: var(--d-border-radius);
194194
transition: outline ease-in-out 0.2s;
195-
padding: 0.25rem;
196195
transition-delay: 0.1s;
197196
}
198197

@@ -207,6 +206,20 @@
207206
&.editing-topic {
208207
transition: none;
209208
}
209+
210+
&.editing-topic #edit-title {
211+
border: none;
212+
font-size: var(--font-up-4);
213+
line-height: var(--line-height-medium);
214+
font-weight: bold;
215+
padding: 0;
216+
resize: none;
217+
height: var(--font-up-4);
218+
}
219+
220+
&.editing-topic #edit-title:focus {
221+
outline: none;
222+
}
210223
}
211224

212225
&.can-edit-topic .title-wrapper .d-icon {

0 commit comments

Comments
 (0)