Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that sidebar field will not steal focus when metadata is edited #5983

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -769,7 +769,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