Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The UX of resizing small images. #9173

Merged
merged 12 commits into from
Mar 16, 2021

Conversation

magda-chrzescian
Copy link
Contributor

@magda-chrzescian magda-chrzescian commented Mar 5, 2021

Suggested merge commit message (convention)

Fix (image): An image should never overflow the widget boundaries while changing its size. Closes #9166.

Fix (image): The size label should be displayed above the image if it doesn't fit inside. See #9166.

Fix (image): An Image caption placeholder text should not wrap. Closes #9162.


AFAIR the SizeView class was not tested directly at all. I exported it (it is declared as public in the API docs) and wrote the tests covering only the purpose of this issue.


Requires #9043.

@magda-chrzescian magda-chrzescian changed the base branch from i/2052-inline-images to i/8777 March 8, 2021 14:05
@oleq oleq self-requested a review March 9, 2021 11:54
@magda-chrzescian magda-chrzescian linked an issue Mar 12, 2021 that may be closed by this pull request
@magda-chrzescian magda-chrzescian marked this pull request as draft March 12, 2021 15:25
@magda-chrzescian magda-chrzescian linked an issue Mar 12, 2021 that may be closed by this pull request
@magda-chrzescian magda-chrzescian marked this pull request as ready for review March 15, 2021 10:52
Base automatically changed from i/8777 to i/2052-inline-images March 16, 2021 08:49
Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally, things look fine 👍 I got are some concerns regarding the implementation and tests, though.

packages/ckeditor5-widget/src/widgetresize/sizeview.js Outdated Show resolved Hide resolved
packages/ckeditor5-widget/src/widgetresize/sizeview.js Outdated Show resolved Hide resolved
packages/ckeditor5-widget/src/widgetresize/sizeview.js Outdated Show resolved Hide resolved
/**
* The position of the view defined based on the host size and active handle position.
*
* @private
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also @readonly, no one will ever write to this property.

Copy link
Contributor Author

@magda-chrzescian magda-chrzescian Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used in tests anymore, so I left it @Private.

Asserting viewPosition makes little sense here IMO because it is an internal component state for binding purposes only. The only thing that matters for this component is the class.

packages/ckeditor5-widget/tests/widgetresize/sizeview.js Outdated Show resolved Hide resolved
bind.to( 'viewPosition', value => value ? `ck-orientation-${ value }` : '' )
],
style: {
display: bind.if( 'isVisible', 'none', visible => !visible )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs for #isVisible. Also, #_isVisible should also be protected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used in tests or outside the class actually, so I made it @Private.

}
},
children: [ {
text: bind.to( 'label' )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #label docs. This also looks like an internal state for template binding purposes, so let's make it @Protected and #_label.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used in tests or outside the class actually, so I made it @Private.

import SizeView from '../../src/widgetresize/sizeview';
import ResizerState from '../../src/widgetresize/resizerstate';

describe( 'SizeView', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're testing this view properly now, then some essential tests are missing:

  • template structure assertion,
  • style.display tests,
  • children text (label) tests.

packages/ckeditor5-image/theme/image.css Show resolved Hide resolved
@oleq oleq merged commit bc9eeb9 into i/2052-inline-images Mar 16, 2021
@oleq oleq deleted the i/9166-resizing-small-images branch March 16, 2021 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The UX of resizing small images looks broken Image caption placeholder wraps for small images
2 participants