Skip to content

Commit 0c7cea2

Browse files
authored
COMPASS-1319: Backport COMPASS-1318 Make EditableElement expand button hit box larger (#1119) (#1122)
* 🐛 COMPASS-1318 Make EditableElement expand button hit box larger By using padding instead of margins, as margins are not clickable, but padding is. * 🐛 Add onClick handler to document keys From review feedback: > Quick question though: would it be easy to include the field name as a clickable area? I believe this got lost at some point. if it's a small change, can you just add it here? Tested against both view mode and editing mode. AFAICT it seems to still respond intuitively, e.g. I can still double-click to select text independent of mode, single click to select a specific part of the key in edit mode, click and drag to select a part of the key in edit mode, etc. More importantly, if I attempt to move the handler upwards into renderExpandable, then in edit mode, clicking on the editable key does NOT toggle the dropdown, which is an easy mistake I nearly made :) * 🔥 Remove unused renderStyle function * 🐛 Increase padding The part between the arrow button and document key also should be clickable.
1 parent 25883f7 commit 0c7cea2

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

src/internal-packages/crud/lib/component/editable-element.jsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,6 @@ class EditableElement extends React.Component {
282282
return (<span className={SEPARATOR}>:</span>);
283283
}
284284

285-
/**
286-
* Render the style with the provided base style.
287-
*
288-
* @param {String} base - The base style.
289-
*
290-
* @returns {String} The style.
291-
*/
292-
renderStyle(base) {
293-
let style = base;
294-
if (this.props.rootFieldIndex > FIELD_LIMIT) {
295-
style = `${style} hidden`;
296-
}
297-
return style;
298-
}
299-
300285
/**
301286
* Render the types column.
302287
*
@@ -320,7 +305,7 @@ class EditableElement extends React.Component {
320305
}
321306
const onDoubleClick = this.element.isKeyEditable() ? null : this.focusEditKey.bind(this);
322307
return (
323-
<div className={FIELD_CLASS} onDoubleClick={onDoubleClick}>
308+
<div className={FIELD_CLASS} onClick={this.toggleExpandable.bind(this)} onDoubleClick={onDoubleClick}>
324309
{this.element.parent.currentType === 'Array' ? this.props.index : this.element.currentKey}
325310
</div>
326311
);
@@ -344,7 +329,7 @@ class EditableElement extends React.Component {
344329
}
345330

346331
/**
347-
* Render the expanable label column.
332+
* Render the expandable label column.
348333
*
349334
* @returns {Component} The component.
350335
*/

src/internal-packages/crud/styles/editable-element.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
&-expand-button {
1515
position: absolute;
16-
margin: 2px 0px 0px 5px;
16+
padding: 2px 6px 0px 5px;
1717
}
1818

1919
&-separator {

0 commit comments

Comments
 (0)