Skip to content

ref: decrease size of block-note toolbar - #25023

Merged
gustavotrott merged 7 commits into
bigbluebutton:v3.0.x-developfrom
GuiLeme:bn-smaller-icons
May 11, 2026
Merged

gustavotrott merged 7 commits into
bigbluebutton:v3.0.x-developfrom
GuiLeme:bn-smaller-icons

Conversation

@GuiLeme

@GuiLeme GuiLeme commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

  • It removes the label from the block type of the block-note toolbar;
  • And it compiles the three types of alignments in one dropdown menu;

That is done so that the toolbar is smaller in order to render in one line for some monitors.

How to test

Play around with the alignment and block-types making sure they don't break

More

See screenshot ahead:
image

@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This change refactors the text alignment UI in shared notes: it adds a new TextAlignSelect dropdown component (left/center/right/justify), replaces the multiple TextAlignButton controls in the secondary FormattingToolbar with this select, updates BlockNote imports, injects toolbar CSS adjustments, and adds the react-icons dependency used by the new component.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FormattingToolbar
  participant TextAlignSelect
  participant Editor
  participant TableHandlesExtension
  User->>FormattingToolbar: open alignment dropdown
  FormattingToolbar->>TextAlignSelect: render options / show current alignment
  User->>TextAlignSelect: choose alignment option
  TextAlignSelect->>Editor: focus() and apply textAlignment to selected blocks
  Editor->>TableHandlesExtension: mapTableCell() for table selection
  TableHandlesExtension->>Editor: return cell mapping
  Editor->>TextAlignSelect: confirm update (selection/cursor updated)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: reducing the block-note toolbar size by consolidating alignment buttons into a dropdown and removing labels.
Description check ✅ Passed The description clearly explains the changes made (removing labels, combining alignment options) and their purpose (reducing toolbar size), with testing instructions and a screenshot.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@GuiLeme
GuiLeme marked this pull request as draft May 6, 2026 20:23
@GuiLeme
GuiLeme requested a review from gustavotrott May 6, 2026 20:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx (1)

47-52: 💤 Low value

editor.focus() called before updateBlock — works but is reversed from BlockNote's own convention.

BlockNote's built-in toolbar buttons consistently call editor.focus() after making changes, not before. Calling it first here is safe in practice (React 18 event-handler batching prevents interleaved re-renders), but aligning with the library's pattern avoids subtle surprises if that batching assumption ever changes.

♻️ Suggested order
  onClick: () => {
-   editor.focus();
    state.blocks.forEach((block) => {
      editor.updateBlock(block, { props: { textAlignment: a.value } as never });
    });
+   editor.focus();
  },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`
around lines 47 - 52, The onClick handler currently calls editor.focus() before
mutating blocks; change the order to perform the updates first and call
editor.focus() afterwards so it matches BlockNote's convention — i.e., in the
onClick for the text-align button, iterate state.blocks and call
editor.updateBlock(block, { props: { textAlignment: a.value } }) first, then
call editor.focus(); keep references to the existing symbols (onClick,
state.blocks, editor.updateBlock, editor.focus) and preserve all other logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx`:
- Around line 244-249: The two new global selectors (.mantine-Button-label and
.mantine-Button-inner > .mantine-Button-section:first-child) must be scoped to
the BlockNote toolbar and the label must remain in the accessibility tree:
update the rules so they are prefixed with .bn-toolbar-row (e.g. .bn-toolbar-row
.mantine-Button-label and .bn-toolbar-row .mantine-Button-inner >
.mantine-Button-section:first-child) and replace display: none on
.mantine-Button-label with a visually-hidden approach (clip/size/overflow
technique or an existing .sr-only utility) so the label is visually hidden but
still readable by screen readers; change the selector references in
component.tsx accordingly.

In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`:
- Around line 17-20: Replace the hardcoded English labels in the alignment items
array so they are internationalized: define messages (e.g. via defineMessages)
for "Left", "Center", "Right", "Justify", obtain intl via useIntl(), and pass
intl.formatMessage(...) as the label for each item used by
Components.FormattingToolbar.Select (the items array in component.tsx using
RiAlignLeft/RiAlignCenter/RiAlignRight/RiAlignJustify). Ensure the same message
IDs are used elsewhere in bn-shared-notes/component.tsx style for consistency
and accessibility.

---

Nitpick comments:
In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`:
- Around line 47-52: The onClick handler currently calls editor.focus() before
mutating blocks; change the order to perform the updates first and call
editor.focus() afterwards so it matches BlockNote's convention — i.e., in the
onClick for the text-align button, iterate state.blocks and call
editor.updateBlock(block, { props: { textAlignment: a.value } }) first, then
call editor.focus(); keep references to the existing symbols (onClick,
state.blocks, editor.updateBlock, editor.focus) and preserve all other logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4d091e4e-83ad-4ff7-9e9b-cbf7f9fc7898

📥 Commits

Reviewing files that changed from the base of the PR and between d16d1a9 and 74ecd1e.

⛔ Files ignored due to path filters (1)
  • bigbluebutton-html5/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx
  • bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx
  • bigbluebutton-html5/package.json

@antobinary antobinary added this to the Release 3.0 milestone May 7, 2026

@TiagoJacobs TiagoJacobs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @GuiLeme

A few comments:

1 - Please adjust the toolbar button alignment.

Image

2 - Please change the button order:
a. Text size (already correct)
b. Text styles (already correct)
c. Alignment tools (needs to move)
d. Color (needs to move)

3 - Please open a PR in BlockNote proposing the alignment dropdown, and add a comment in the code with the PR link so that, if they merge it in the future, we can easily remove our custom implementation.

@sonarqubecloud

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

✅ Automated tests have passed!

@GuiLeme
GuiLeme marked this pull request as ready for review May 11, 2026 13:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx (1)

80-93: ⚖️ Poor tradeoff

Consider extracting table cell mapping logic to reduce nesting.

The nested maps at line 82 create a 5-level nesting depth (function → forEach → else if → map → map), exceeding the typical 4-level guideline flagged by SonarCloud. While the logic is correct, extracting the table cell transformation into a helper function would improve readability and maintainability.

♻️ Optional refactor to reduce nesting
+const updateTableCellsAlignment = (
+  rows: TableContent<never, never>['rows'],
+  cellSelection: { row: number; col: number }[],
+  alignment: TextAlignment
+) => {
+  const newTable = rows.map((row) => ({
+    ...row,
+    cells: row.cells.map((cell) => mapTableCell(cell)),
+  }));
+
+  cellSelection.forEach(({ row, col }) => {
+    newTable[row].cells[col] = {
+      ...newTable[row].cells[col],
+      props: {
+        ...newTable[row].cells[col].props,
+        textAlignment: alignment,
+      },
+    };
+  });
+
+  return newTable;
+};
+
 const setTextAlignment = useCallback(
   (alignment: TextAlignment) => {
     // ... existing code ...
     } else if (block.type === 'table') {
       const cellSelection = editor.getExtension(TableHandlesExtension)?.getCellSelection();
       if (!cellSelection) return;

-      const newTable = (block.content as TableContent<never, never>).rows.map((row) => ({
-        ...row,
-        cells: row.cells.map((cell) => mapTableCell(cell)),
-      }));
-
-      cellSelection.cells.forEach(({ row, col }) => {
-        newTable[row].cells[col] = {
-          ...newTable[row].cells[col],
-          props: {
-            ...newTable[row].cells[col].props,
-            textAlignment: alignment,
-          },
-        };
-      });
+      const newTable = updateTableCellsAlignment(
+        (block.content as TableContent<never, never>).rows,
+        cellSelection.cells,
+        alignment
+      );

       editor.updateBlock(block, {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`
around lines 80 - 93, The current nested mapping/forEach that builds newTable
and applies alignment (using mapTableCell and cellSelection) creates excessive
nesting; extract the table transformation into a helper (e.g.,
mapTableWithAlignment or applyAlignmentToTableCells) that accepts the
TableContent (block.content), the alignment value, and the cellSelection,
returns the transformed rows/cells with updated props.textAlignment, and then
replace the inline maps/forEach with a single call to that helper; ensure the
helper reuses mapTableCell for individual cell mapping and updates targeted
cells by row/col while preserving other cell props.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx`:
- Around line 80-93: The current nested mapping/forEach that builds newTable and
applies alignment (using mapTableCell and cellSelection) creates excessive
nesting; extract the table transformation into a helper (e.g.,
mapTableWithAlignment or applyAlignmentToTableCells) that accepts the
TableContent (block.content), the alignment value, and the cellSelection,
returns the transformed rows/cells with updated props.textAlignment, and then
replace the inline maps/forEach with a single call to that helper; ensure the
helper reuses mapTableCell for individual cell mapping and updates targeted
cells by row/col while preserving other cell props.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1ef1ea59-b81d-4818-baf9-d9f8d7654e43

📥 Commits

Reviewing files that changed from the base of the PR and between 74ecd1e and 252bc5b.

📒 Files selected for processing (2)
  • bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx
  • bigbluebutton-html5/imports/ui/components/bn-shared-notes/text-align-select/component.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx

@gustavotrott gustavotrott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gustavotrott
gustavotrott merged commit e93d357 into bigbluebutton:v3.0.x-develop May 11, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants