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

fix(popover): i18n in nested popover #2779

Merged
merged 1 commit into from
Jul 11, 2024
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
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 2.30.3

- `Fix` – I18n in nested popover

### 2.30.2

- `Fix` – The onChange callback won't be fired when editor is initialized in the Read-Only mode
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/editorjs",
"version": "2.30.2",
"version": "2.30.3",
"description": "Editor.js — open source block-style WYSIWYG editor with JSON output",
"main": "dist/editorjs.umd.js",
"module": "dist/editorjs.mjs",
Expand Down
1 change: 1 addition & 0 deletions src/components/utils/popover/popover-desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export class PopoverDesktop extends PopoverAbstract {
items: item.children,
nestingLevel: this.nestingLevel + 1,
flippable: item.isChildrenFlippable,
messages: this.messages,
});

item.onChildrenOpen();
Expand Down
89 changes: 89 additions & 0 deletions test/cypress/tests/utils/popover.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,95 @@ describe('Popover', () => {
.should('exist');
});

it.only('shoould support i18n in nested popover', () => {
/**
*
*/
class TestTune {
public static isTune = true;

/** Tool data displayed in block tunes popover */
public render(): MenuConfig {
return {
icon: 'Icon',
title: 'Title',
toggle: 'key',
name: 'test-item',
children: {
searchable: true,
items: [
{
icon: 'Icon',
title: 'Title',
name: 'nested-test-item',
onActivate: (): void => {},
},
],
},
};
}
}

/** Create editor instance */
cy.createEditor({
tools: {
testTool: TestTune,
},
tunes: [ 'testTool' ],
data: {
blocks: [
{
type: 'paragraph',
data: {
text: 'Hello',
},
},
],
},
i18n: {
messages: {
ui: {
popover: {
'Filter': 'Искать',
// eslint-disable-next-line @typescript-eslint/naming-convention -- i18n
'Nothing found': 'Ничего не найдено',
},
},
},
},
});

/** Open block tunes menu */
cy.get('[data-cy=editorjs]')
.get('.cdx-block')
.click();

cy.get('[data-cy=editorjs]')
.get('.ce-toolbar__settings-btn')
.click();

/** Click the item */
cy.get('[data-cy=editorjs]')
.get('[data-item-name="test-item"]')
.click();

/** Check nested popover search input has placeholder text with i18n */
cy.get('[data-cy=editorjs]')
.get('[data-cy=block-tunes] .ce-popover--nested .cdx-search-field__input')
.invoke('attr', 'placeholder')
.should('eq', 'Искать');

/** Enter search query */
cy.get('[data-cy=editorjs]')
.get('[data-cy=block-tunes] .ce-popover--nested .cdx-search-field__input')
.type('Some text');

/** Check nested popover has nothing found message with i18n */
cy.get('[data-cy=editorjs]')
.get('[data-cy=block-tunes] .ce-popover--nested .ce-popover__nothing-found-message')
.should('have.text', 'Ничего не найдено');
});

describe('Inline Popover', () => {
it('should open nested popover on click instead of hover', () => {
cy.createEditor({
Expand Down
Loading