Skip to content

Commit

Permalink
fix: handle initial render to avoid ui flashing
Browse files Browse the repository at this point in the history
  • Loading branch information
jarekdanielak committed Jul 18, 2024
1 parent bdf8f13 commit 5c48e7b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/entries/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ function TextArea(props) {
setLocalValue(e.target.value);
};

useLayoutEffect(() => {
autoResize && resizeToContents(ref.current);
}, []);

useLayoutEffect(() => {
visible && autoResize && resizeToContents(ref.current);
}, [ visible ]);
Expand Down
28 changes: 28 additions & 0 deletions test/spec/components/TextArea.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,34 @@ describe('<TextArea>', function() {

describe('auto resize', function() {

it('should resize initially', async function() {

// given
const result = createTextArea({
container,
id: 'textarea',
getValue() {
return `
1
2
3
4`;
},
autoResize: true
});

const input = domQuery('.bio-properties-panel-input', result.container);

// when
const initialHeight = input.clientHeight;

// then
await waitFor(() => {
expect(initialHeight).to.be.greaterThan(60);
});
});


it('should resize on input', function() {

// given
Expand Down

0 comments on commit 5c48e7b

Please sign in to comment.