mirror of
https://github.com/discourse/discourse.git
synced 2025-03-14 10:33:43 +00:00
FIX: Disable composer editor switch when uploading (#31789)
When you are uploading, it just causes weird problems when you switch between markdown/rich editors, and it's not something we really want to support. This commit disables the Composer::ToggleSwitch while uploading.
This commit is contained in:
@ -43,6 +43,7 @@
|
|||||||
@topicId={{this.composer.model.topic.id}}
|
@topicId={{this.composer.model.topic.id}}
|
||||||
@categoryId={{this.composer.model.category.id}}
|
@categoryId={{this.composer.model.category.id}}
|
||||||
@onSetup={{this.setupEditor}}
|
@onSetup={{this.setupEditor}}
|
||||||
|
@disableSubmit={{this.composer.disableSubmit}}
|
||||||
>
|
>
|
||||||
{{yield}}
|
{{yield}}
|
||||||
</DEditor>
|
</DEditor>
|
||||||
|
@ -30,6 +30,7 @@ export default class ComposerToggleSwitch extends Component {
|
|||||||
}}
|
}}
|
||||||
type="button"
|
type="button"
|
||||||
role="switch"
|
role="switch"
|
||||||
|
disabled={{@disabled}}
|
||||||
aria-checked={{if @state "true" "false"}}
|
aria-checked={{if @state "true" "false"}}
|
||||||
aria-label={{this.label}}
|
aria-label={{this.label}}
|
||||||
title={{this.label}}
|
title={{this.label}}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
{{#if this.siteSettings.rich_editor}}
|
{{#if this.siteSettings.rich_editor}}
|
||||||
<Composer::ToggleSwitch
|
<Composer::ToggleSwitch
|
||||||
@preventFocus={{true}}
|
@preventFocus={{true}}
|
||||||
|
@disabled={{@disableSubmit}}
|
||||||
@state={{this.isRichEditorEnabled}}
|
@state={{this.isRichEditorEnabled}}
|
||||||
{{on "click" this.toggleRichEditor}}
|
{{on "click" this.toggleRichEditor}}
|
||||||
/>
|
/>
|
||||||
|
@ -450,4 +450,20 @@ describe "Composer - ProseMirror editor", type: :system do
|
|||||||
expect(rich).to have_css("p", count: 2) # New paragraph inserted after the ruler
|
expect(rich).to have_css("p", count: 2) # New paragraph inserted after the ruler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "uploads" do
|
||||||
|
it "handles uploads and disables the editor toggle while uploading" do
|
||||||
|
open_composer_and_toggle_rich_editor
|
||||||
|
|
||||||
|
file_path = file_from_fixtures("logo.png", "images").path
|
||||||
|
cdp.with_slow_upload do
|
||||||
|
attach_file(file_path) { composer.click_toolbar_button("upload") }
|
||||||
|
expect(composer).to have_in_progress_uploads
|
||||||
|
expect(composer.editor_toggle_switch).to be_disabled
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(composer).to have_no_in_progress_uploads
|
||||||
|
expect(rich).to have_css("img", count: 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -297,10 +297,14 @@ module PageObjects
|
|||||||
end
|
end
|
||||||
|
|
||||||
def toggle_rich_editor
|
def toggle_rich_editor
|
||||||
find("#{COMPOSER_ID} .composer-toggle-switch").click
|
editor_toggle_switch.click
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def editor_toggle_switch
|
||||||
|
find("#{COMPOSER_ID} .composer-toggle-switch")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def emoji_preview_selector(emoji)
|
def emoji_preview_selector(emoji)
|
||||||
|
Reference in New Issue
Block a user