Skip to content

Commit f1a7e8d

Browse files
authored
fix(rich-text-editor): Fixes select dropdown overlapping issue on smaller screen sizes (#2812)
fix(rich-text-editor): Added docs fix(rich-text-editor): Changed css that targeted value attributes to apply styles via class names fix(rich-text-editor): changed class names to be more sematic fix(rich-text-editor): added bottom margin to font class to even out toolbar spacing fix(rich-text-editor): Scoped a combobox max-width to a slds-region_narrow class fix(rich-text-editor): Added snapshot test for toolbar narrow fix(rich-text-editor): Removed unnecessary CSS and updated docs fix(rich-text-editor): fixed docs typo + fixed issue where RTE shows no vertical space between selects and next row fix(rich-text-editor): Updated annotations for narrow class fix(rich-text-editor): Updated css to add margin bottom on narrow region to slds-grid fix(rich-text-editor): added a class to apply spacing to fix(rich-text-editor): Updated markup
1 parent fafd882 commit f1a7e8d

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
2+
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
3+
/* eslint-env jest */
4+
5+
import React from 'react';
6+
import createHelpers from '../../../../jest.setup';
7+
import {
8+
RichTextEditor,
9+
RteToolbar,
10+
RteFormatFont,
11+
RteFormatText,
12+
RteFormatColor,
13+
RteFormatBody,
14+
RteAlignText,
15+
RteInsertContent,
16+
RteClearFormatting,
17+
RteTextarea
18+
} from '../base/example';
19+
20+
const { matchesMarkupAndStyle } = createHelpers(__dirname);
21+
22+
it('renders an RTE toolbar in a narrow space', () =>
23+
matchesMarkupAndStyle(
24+
<div className="slds-region_narrow">
25+
<RichTextEditor>
26+
<RteToolbar>
27+
<RteFormatFont />
28+
<RteFormatText tabIndexSetting="-1" />
29+
<RteFormatColor />
30+
<RteFormatBody />
31+
<RteAlignText />
32+
<RteInsertContent />
33+
<RteClearFormatting />
34+
</RteToolbar>
35+
36+
<RteTextarea placeholder="Compose Email..." />
37+
</RichTextEditor>
38+
</div>
39+
));

ui/components/rich-text-editor/_doc.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
* The “clear formatting” button always stays at the end of the buttons set,
99
* regardless of which rich text editor variant is used. It should always stand by itself.
1010
*
11+
* On smaller screen sizes, the select dropdowns for Font and Size in the toolbar can overlap
12+
* outside of the container. To adjust the widths of the dropdowns, apply the class
13+
* `slds-region_narrow` to the outermost `div` of the rich text editor.
14+
*
15+
*
1116
* #### Accessibility
1217
*
1318
* Ensure that there is a single tab key stop for the button groups in the

ui/components/rich-text-editor/base/_index.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@
6666
margin-right: $spacing-xx-small;
6767
}
6868

69+
// This class should be placed on a containing div when RTE toolbar is in a small space
70+
.slds-region_narrow {
71+
72+
.slds-combobox {
73+
max-width: 11rem;
74+
}
75+
76+
.slds-rich-text-editor__spacing-wrapper {
77+
margin-bottom: $spacing-xx-small;
78+
}
79+
}
80+
6981
/**
7082
* Focus state for rich text editor
7183
*

ui/components/rich-text-editor/base/example.jsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ const listboxOptionId04 = 'listbox-option-unique-id-04';
2525
/// ////////////////////////////////////////
2626

2727
export let Demo = props => (
28-
<div className="demo-only" style={{ minHeight: '180px' }}>
28+
<div
29+
className={classNames('demo-only', props.className)}
30+
style={{ minHeight: '180px' }}
31+
{...props}
32+
>
2933
{props.children}
3034
</div>
3135
);
@@ -99,7 +103,7 @@ const FontSizeDropdown = props => (
99103

100104
export let RteFormatFont = props => (
101105
<div
102-
className="slds-grid"
106+
className="slds-grid slds-rich-text-editor__spacing-wrapper"
103107
role="group"
104108
aria-label="Format font family &amp; size"
105109
>
@@ -654,6 +658,27 @@ export let examples = [
654658
</Demo>
655659
)
656660
},
661+
{
662+
id: 'toolbar-narrow',
663+
label: 'Toolbar Narrow',
664+
element: (
665+
<Demo style={{ width: '294px' }} className="slds-region_narrow">
666+
<RichTextEditor>
667+
<RteToolbar>
668+
<RteFormatFont />
669+
<RteFormatText tabIndexSetting="-1" />
670+
<RteFormatColor />
671+
<RteFormatBody />
672+
<RteAlignText />
673+
<RteInsertContent />
674+
<RteClearFormatting />
675+
</RteToolbar>
676+
677+
<RteTextarea placeholder="Compose Email..." />
678+
</RichTextEditor>
679+
</Demo>
680+
)
681+
},
657682
{
658683
id: 'feed',
659684
label: 'Feed',

0 commit comments

Comments
 (0)