Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Notes: Highlight the text an unsent note is about, and keep the note anchored to it when the selection changes or the text is edited before the note is sent ([#84125](https://github.com/WordPress/gutenberg/pull/84125)).
- Notes: Select the note under the caret: an inline note while the caret is inside its highlight, otherwise the block's unsent draft or block-level note, instead of an inline note on any click in the block ([#84147](https://github.com/WordPress/gutenberg/pull/84147)).
- Visual History: Render the inline removed-text diff (`<del>`) at the theme's body color over a red-tinted background instead of recoloring it with a translucent color-matrix filter, so it keeps the theme's WCAG AA contrast on any background ([#82258](https://github.com/WordPress/gutenberg/pull/82258)).
- Notes: Stop announcing the "Add note" block menu item as opening a dialog ([#84818](https://github.com/WordPress/gutenberg/pull/84818)).

### Internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,37 @@ import { unlock } from '../../lock-unlock';
const { NoteIconSlotFill } = unlock( blockEditorPrivateApis );

function NoteMenuItem( { clientId, onClick, isDistractionFree } ) {
const block = useSelect(
const { blockName, isValid, shortcut } = useSelect(
( select ) => {
return select( blockEditorStore ).getBlock( clientId );
const { getBlockName, isBlockValid } = select( blockEditorStore );
return {
blockName: getBlockName( clientId ),
isValid: isBlockValid( clientId ),
shortcut: select(
keyboardShortcutsStore
).getShortcutRepresentation( 'core/editor/new-note' ),
};
},
[ clientId ]
);
const shortcut = useSelect(
( select ) =>
select( keyboardShortcutsStore ).getShortcutRepresentation(
'core/editor/new-note'
),
[]
);

if (
! block?.isValid ||
block?.name === getUnregisteredTypeHandlerName()
) {
if ( ! isValid || blockName === getUnregisteredTypeHandlerName() ) {
return null;
}

const isDisabled = isDistractionFree || block?.name === 'core/freeform';
const isDisabled = isDistractionFree || blockName === 'core/freeform';

let infoText;

if ( isDistractionFree ) {
infoText = __( 'Notes are disabled in distraction free mode.' );
} else if ( block?.name === 'core/freeform' ) {
} else if ( blockName === 'core/freeform' ) {
infoText = __( 'Convert to blocks to add notes.' );
}

return (
<MenuItem
onClick={ onClick }
aria-haspopup="dialog"
disabled={ isDisabled }
info={ infoText }
shortcut={ shortcut }
Expand Down
Loading