Skip to content

Commit

Permalink
fix(FeelEditor): focus editor on container click
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm committed Sep 6, 2022
1 parent 7236525 commit 2ed1536
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/entries/FEEL/FeelEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,17 @@ const CodeEditor = forwardRef((props, ref) => {
setLocalValue(value);
}, [ value ]);

const handleClick = () => {
ref.current.focus();
};

return <div class={ classNames('bio-properties-panel-feel-editor-container', disabled ? 'disabled' : null) }>
<div name={ props.name } class={ classNames('bio-properties-panel-input', localValue ? 'edited' : null) } ref={ inputRef }></div>
<div
name={ props.name }
class={ classNames('bio-properties-panel-input', localValue ? 'edited' : null) }
ref={ inputRef }
onClick={ handleClick }
></div>
</div>;
});

Expand Down
16 changes: 16 additions & 0 deletions test/spec/components/FeelEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ describe('<FeelEditor>', function() {
expect(suggestions.children).to.have.length(1);
});


it('should focus on container click', async function() {

// given
render(<Wrapper />, { container });

const input = domQuery('.bio-properties-panel-input', container);
const editor = domQuery('[role="textbox"]', container);

// when
input.click();

// then
expect(document.activeElement).to.equal(editor);
});

});


Expand Down

0 comments on commit 2ed1536

Please sign in to comment.