Skip to content

Commit

Permalink
Merge pull request #2080 from tf/no-select-on-add
Browse files Browse the repository at this point in the history
Do not switch to section settings when adding section
  • Loading branch information
tf authored Feb 23, 2024
2 parents 7c2cf23 + ce2ae41 commit f94f191
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
6 changes: 2 additions & 4 deletions entry_types/scrolled/package/src/editor/models/Chapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Chapter = Backbone.Model.extend({
this.entry = options.entry;
},

addSection(attributes, {select, ...options} = {}) {
addSection(attributes, options) {
const section = this.sections.create(
new Section(
{
Expand All @@ -51,9 +51,7 @@ export const Chapter = Backbone.Model.extend({
);

section.once('sync', (model, response) => {
if (select) {
this.entry.trigger('selectSectionSettings', section);
}
this.entry.trigger('selectSection', section);
this.entry.trigger('scrollToSection', section);

section.configuration.set(response.configuration, {autoSave: false});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const ChapterItemView = Marionette.Layout.extend({

events: cssModulesUtils.events(styles, {
'click addSection': function() {
this.model.addSection({}, {select: true});
this.model.addSection({});
},

'click link': function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export function SectionDecorator({section, contentElements, children}) {
type: 'sectionSettings'
});

const {isSelected: isHighlighted} = useEditorSelection({
id: section.id,
type: 'section'
});

const transitionSelection = useEditorSelection({
id: section.id,
type: 'sectionTransition'
Expand All @@ -45,7 +50,7 @@ export function SectionDecorator({section, contentElements, children}) {

return (
<div aria-label={t('pageflow_scrolled.inline_editing.select_section')}
className={className(isSelected, transitionSelection)}
className={className(isSelected, transitionSelection, isHighlighted)}
onMouseDown={selectIfOutsideContentItem}>
<div className={styles.controls}>
{renderEditTransitionButton({id: section.previousSection && section.id,
Expand All @@ -64,9 +69,10 @@ export function SectionDecorator({section, contentElements, children}) {
);
}

function className(isSectionSelected, transitionSelection) {
function className(isSectionSelected, transitionSelection, isHighlighted) {
return classNames(styles.wrapper, {
[styles.selected]: isSectionSelected,
[styles.highlighted]: isHighlighted,
[styles.transitionSelected]: transitionSelection.isSelected
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
position: relative;
}

.highlighted > section::before,
.selected > section::before {
content: "";
display: block;
Expand All @@ -15,6 +16,10 @@
pointer-events: none;
}

.highlighted > section::before {
opacity: 0.3;
}

.transitionSelected > section:before {
content: "";
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
chapter_item = outline.chapter_items.first
chapter_item.add_section_button.click

Pageflow::Dom::Editor::EditConfigurationView.find!.back_button.click
chapter_item = outline.chapter_items.first
expect(chapter_item.section_items.size).to eq(1)

chapter_item.section_items.first.thumbnail.double_click
Expand Down

0 comments on commit f94f191

Please sign in to comment.