@atlaskit/editor-plugin-card 6.4.0 → 6.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 6.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#161870](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/161870)
8
+ [`f2008aed97498`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2008aed97498) -
9
+ Set default value of open text to null
10
+ - Updated dependencies
11
+
3
12
  ## 6.4.0
4
13
 
5
14
  ### Minor Changes
@@ -97,13 +97,14 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
97
97
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
98
98
  isHovered = _useState4[0],
99
99
  setHovered = _useState4[1];
100
- var openTextWidthRef = (0, _react.useRef)(DEFAULT_OPEN_TEXT_WIDTH);
100
+ var openTextWidthRef = (0, _react.useRef)(null);
101
101
  (0, _react.useLayoutEffect)(function () {
102
102
  if ((0, _experiments.editorExperiment)('platform_editor_smart_card_open_overlay_perf', false, {
103
103
  exposure: true
104
104
  })) {
105
105
  var hiddenText = hiddenTextRef.current;
106
106
  if (!hiddenText) {
107
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
107
108
  return;
108
109
  }
109
110
  // Measure the width of the hidden text
@@ -131,27 +132,28 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
131
132
  })) {
132
133
  if (!openTextWidthRef.current) {
133
134
  var hiddenText = hiddenTextRef.current;
134
- if (!hiddenText) {
135
- return;
136
- }
137
-
138
- // Measure the width of the hidden text
139
- // Temporarily make the element visible to measure its width
140
- hiddenText.style.visibility = 'hidden';
141
- hiddenText.style.display = 'inline';
142
- openTextWidthRef.current = hiddenText.offsetWidth;
135
+ if (hiddenText) {
136
+ // Measure the width of the hidden text
137
+ // Temporarily make the element visible to measure its width
138
+ hiddenText.style.visibility = 'hidden';
139
+ hiddenText.style.display = 'inline';
140
+ openTextWidthRef.current = hiddenText.offsetWidth;
143
141
 
144
- // Reset the hiddenText's display property
145
- hiddenText.style.display = 'none';
146
- hiddenText.style.visibility = 'inherit';
142
+ // Reset the hiddenText's display property
143
+ hiddenText.style.display = 'none';
144
+ hiddenText.style.visibility = 'inherit';
145
+ } else {
146
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
147
+ }
147
148
  }
148
149
  }
149
150
  if (!cardWidth || !openButtonWidth) {
150
151
  return;
151
152
  }
153
+ var openTextWidth = openTextWidthRef.current || DEFAULT_OPEN_TEXT_WIDTH;
152
154
  var canShowLabel = true;
153
155
  if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_2')) {
154
- canShowLabel = cardWidth - openTextWidthRef.current > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
156
+ canShowLabel = cardWidth - openTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
155
157
  } else {
156
158
  canShowLabel = cardWidth - openButtonWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY;
157
159
  }
@@ -77,13 +77,14 @@ const OpenButtonOverlay = ({
77
77
  const hiddenTextRef = useRef(null);
78
78
  const [showLabel, setShowLabel] = useState(true);
79
79
  const [isHovered, setHovered] = useState(false);
80
- const openTextWidthRef = useRef(DEFAULT_OPEN_TEXT_WIDTH);
80
+ const openTextWidthRef = useRef(null);
81
81
  useLayoutEffect(() => {
82
82
  if (editorExperiment('platform_editor_smart_card_open_overlay_perf', false, {
83
83
  exposure: true
84
84
  })) {
85
85
  const hiddenText = hiddenTextRef.current;
86
86
  if (!hiddenText) {
87
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
87
88
  return;
88
89
  }
89
90
  // Measure the width of the hidden text
@@ -111,27 +112,28 @@ const OpenButtonOverlay = ({
111
112
  })) {
112
113
  if (!openTextWidthRef.current) {
113
114
  const hiddenText = hiddenTextRef.current;
114
- if (!hiddenText) {
115
- return;
116
- }
117
-
118
- // Measure the width of the hidden text
119
- // Temporarily make the element visible to measure its width
120
- hiddenText.style.visibility = 'hidden';
121
- hiddenText.style.display = 'inline';
122
- openTextWidthRef.current = hiddenText.offsetWidth;
115
+ if (hiddenText) {
116
+ // Measure the width of the hidden text
117
+ // Temporarily make the element visible to measure its width
118
+ hiddenText.style.visibility = 'hidden';
119
+ hiddenText.style.display = 'inline';
120
+ openTextWidthRef.current = hiddenText.offsetWidth;
123
121
 
124
- // Reset the hiddenText's display property
125
- hiddenText.style.display = 'none';
126
- hiddenText.style.visibility = 'inherit';
122
+ // Reset the hiddenText's display property
123
+ hiddenText.style.display = 'none';
124
+ hiddenText.style.visibility = 'inherit';
125
+ } else {
126
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
127
+ }
127
128
  }
128
129
  }
129
130
  if (!cardWidth || !openButtonWidth) {
130
131
  return;
131
132
  }
133
+ const openTextWidth = openTextWidthRef.current || DEFAULT_OPEN_TEXT_WIDTH;
132
134
  let canShowLabel = true;
133
135
  if (fg('platform_editor_controls_patch_2')) {
134
- canShowLabel = cardWidth - openTextWidthRef.current > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
136
+ canShowLabel = cardWidth - openTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
135
137
  } else {
136
138
  canShowLabel = cardWidth - openButtonWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY;
137
139
  }
@@ -83,13 +83,14 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
83
83
  _useState4 = _slicedToArray(_useState3, 2),
84
84
  isHovered = _useState4[0],
85
85
  setHovered = _useState4[1];
86
- var openTextWidthRef = useRef(DEFAULT_OPEN_TEXT_WIDTH);
86
+ var openTextWidthRef = useRef(null);
87
87
  useLayoutEffect(function () {
88
88
  if (editorExperiment('platform_editor_smart_card_open_overlay_perf', false, {
89
89
  exposure: true
90
90
  })) {
91
91
  var hiddenText = hiddenTextRef.current;
92
92
  if (!hiddenText) {
93
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
93
94
  return;
94
95
  }
95
96
  // Measure the width of the hidden text
@@ -117,27 +118,28 @@ var OpenButtonOverlay = function OpenButtonOverlay(_ref) {
117
118
  })) {
118
119
  if (!openTextWidthRef.current) {
119
120
  var hiddenText = hiddenTextRef.current;
120
- if (!hiddenText) {
121
- return;
122
- }
123
-
124
- // Measure the width of the hidden text
125
- // Temporarily make the element visible to measure its width
126
- hiddenText.style.visibility = 'hidden';
127
- hiddenText.style.display = 'inline';
128
- openTextWidthRef.current = hiddenText.offsetWidth;
121
+ if (hiddenText) {
122
+ // Measure the width of the hidden text
123
+ // Temporarily make the element visible to measure its width
124
+ hiddenText.style.visibility = 'hidden';
125
+ hiddenText.style.display = 'inline';
126
+ openTextWidthRef.current = hiddenText.offsetWidth;
129
127
 
130
- // Reset the hiddenText's display property
131
- hiddenText.style.display = 'none';
132
- hiddenText.style.visibility = 'inherit';
128
+ // Reset the hiddenText's display property
129
+ hiddenText.style.display = 'none';
130
+ hiddenText.style.visibility = 'inherit';
131
+ } else {
132
+ openTextWidthRef.current = DEFAULT_OPEN_TEXT_WIDTH;
133
+ }
133
134
  }
134
135
  }
135
136
  if (!cardWidth || !openButtonWidth) {
136
137
  return;
137
138
  }
139
+ var openTextWidth = openTextWidthRef.current || DEFAULT_OPEN_TEXT_WIDTH;
138
140
  var canShowLabel = true;
139
141
  if (fg('platform_editor_controls_patch_2')) {
140
- canShowLabel = cardWidth - openTextWidthRef.current > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
142
+ canShowLabel = cardWidth - openTextWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY + ICON_WIDTH;
141
143
  } else {
142
144
  canShowLabel = cardWidth - openButtonWidth > MIN_AVAILABLE_SPACE_WITH_LABEL_OVERLAY;
143
145
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "6.4.0",
3
+ "version": "6.4.1",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/analytics-next": "^11.0.0",
38
38
  "@atlaskit/button": "^23.2.0",
39
39
  "@atlaskit/custom-steps": "^0.11.0",
40
- "@atlaskit/editor-common": "^105.11.0",
40
+ "@atlaskit/editor-common": "^106.0.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
42
42
  "@atlaskit/editor-plugin-base": "^3.0.0",
43
43
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",