From f7f66431792978516575eaa439f57ad61f18616f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Thu, 25 Mar 2021 10:32:48 +0200 Subject: [PATCH] RichText: add min width to show caret for empty inline container --- packages/rich-text/src/component/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/rich-text/src/component/index.js b/packages/rich-text/src/component/index.js index 6a14db55369d2..3451299e02b7c 100644 --- a/packages/rich-text/src/component/index.js +++ b/packages/rich-text/src/component/index.js @@ -83,12 +83,18 @@ const INSERTION_INPUT_TYPES_TO_IGNORE = new Set( [ */ const whiteSpace = 'pre-wrap'; +/** + * A minimum width of 1px will prevent the rich text container from collapsing + * to 0 width and hiding the caret. This is useful for inline containers. + */ +const minWidth = '1px'; + /** * Default style object for the editable element. * * @type {Object} */ -const defaultStyle = { whiteSpace }; +const defaultStyle = { whiteSpace, minWidth }; const EMPTY_ACTIVE_FORMATS = [];