Skip to content

Commit

Permalink
Fix tabbing in widgets not triggering auto-scrolling (#26139)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 authored Oct 15, 2020
1 parent 7178f23 commit 935d70a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { Popover } from '@wordpress/components';
import {
BlockList,
BlockEditorKeyboardShortcuts,
BlockSelectionClearer,
WritingFlow,
ObserveTyping,
} from '@wordpress/block-editor';
import { useDispatch } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -17,31 +17,27 @@ import Notices from '../notices';
import KeyboardShortcuts from '../keyboard-shortcuts';

export default function WidgetAreasBlockEditorContent() {
const { clearSelectedBlock } = useDispatch( 'core/block-editor' );

return (
<>
<KeyboardShortcuts />
<BlockEditorKeyboardShortcuts />
<Notices />
<Popover.Slot name="block-toolbar" />
<div tabIndex="-1" onFocus={ clearSelectedBlock }>
<div
className="editor-styles-wrapper"
onFocus={ ( event ) => {
// Stop propagation of the focus event to avoid the parent
// widget layout component catching the event and removing the selected area.
event.stopPropagation();
event.preventDefault();
} }
>
<WritingFlow>
<ObserveTyping>
<BlockList className="edit-widgets-main-block-list" />
</ObserveTyping>
</WritingFlow>
</div>
<BlockSelectionClearer>
<div
className="edit-widgets-block-editor editor-styles-wrapper"
onFocus={ ( event ) => {
// Stop propagation of the focus event to avoid the parent
// widget layout component catching the event and removing the selected area.
event.stopPropagation();

This comment has been minimized.

Copy link
@ellatrix

ellatrix Dec 16, 2020

Member

It's bad practice to stop propagation of events, which parent components may want to listen too. Is there no other way to fix the issue?

event.preventDefault();
} }
>
<KeyboardShortcuts />
<BlockEditorKeyboardShortcuts />
<Notices />
<Popover.Slot name="block-toolbar" />
<WritingFlow>
<ObserveTyping>
<BlockList className="edit-widgets-main-block-list" />
</ObserveTyping>
</WritingFlow>
</div>
</>
</BlockSelectionClearer>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.edit-widgets-block-editor {
position: relative;
}
1 change: 1 addition & 0 deletions packages/edit-widgets/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@import "./components/sidebar/style.scss";
@import "./components/notices/style.scss";
@import "./components/layout/style.scss";
@import "./components/widget-areas-block-editor-content/style.scss";

// In order to use mix-blend-mode, this element needs to have an explicitly set background-color
// We scope it to .wp-toolbar to be wp-admin only, to prevent bleed into other implementations
Expand Down

0 comments on commit 935d70a

Please sign in to comment.