Skip to content

Commit

Permalink
Ensure that sidebar field will not steal focus when metadata is edited (
Browse files Browse the repository at this point in the history
  • Loading branch information
dobri1408 authored Jun 21, 2024
1 parent 78dc98b commit 50bba48
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/volto/cypress/tests/core/basic/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,15 @@ describe('Add Content Tests', () => {
.contains('Required input is missing');
cy.get('.sidebar-container .tabs-wrapper .active.item').contains('Page');
});

it('After removing value of widget the focus should be removed from the field', () => {
cy.get('#field-creators').type('aaa');
cy.get('#field-creators')
.type('aaa{Enter}')
.get('.react-select__multi-value__remove')
.click();
cy.getSlateEditorAndType(
'Test if all the text will be in this slate block',
).contains('Test if all the text will be in this slate block');
});
});
1 change: 1 addition & 0 deletions packages/volto/news/5983.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure that sidebar field will not steal focus when metadata is edited @dobri1408
9 changes: 8 additions & 1 deletion packages/volto/src/components/manage/Form/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,14 @@ class Form extends Component {
id={field}
fieldSet={fieldset.title.toLowerCase()}
formData={formData}
focus={this.state.inFocus[field]}
focus={
this.state.isClient &&
document
.getElementById('sidebar-metadata')
?.contains(document.activeElement)
? this.state.inFocus[field]
: false
}
value={formData?.[field]}
required={
schema.required.indexOf(field) !== -1
Expand Down

0 comments on commit 50bba48

Please sign in to comment.