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

Dialogs system implementation #15285

Merged
merged 206 commits into from
Jan 9, 2024
Merged

Dialogs system implementation #15285

merged 206 commits into from
Jan 9, 2024

Conversation

oleq
Copy link
Member

@oleq oleq commented Oct 31, 2023

Suggested merge commit message (convention)

Feature (ui): Implemented the Dialog plugin that allows for displaying dialog windows in the UI of the editor. Learn more about using dialogs. Closes #14973.
Feature (find-and-replace): The UI of the feature has been migrated to a dialog for a better user experience. See #14973.

Fix (ui): TextareaView component should update its size if its value has been changed while it was invisible. See #14973.
Other (ui): The FocusCycler#focusables collection should only contain FocusableView instances. See #14973.
Other (ui): The #next and #previous properties of a FocusCycler instance should point to the same view if there is only one focusable view registered in the focusables collection. See #14973.

BREAKING CHANGE (find-and-replace): From this release on, the UI of the Find and replace feature is displayed by default in a dialog instead of a dropdown. To bring the previous user experience back, you can use the config.findAndReplace.uiType configuration option. See #14973.

MINOR BREAKING CHANGE (ui): The --ck-z-modal CSS custom property has been renamed to --ck-z-panel. We recommend updating custom CSS and integrations that use this custom property to avoid presentation issues. See #14973.
MINOR BREAKING CHANGE (find-and-replace): The layout of the UI has been changed. Please keep in mind that customizations based on certain CSS selectors may not work anymore because of a different DOM structure in the UI. Learn more about the scope of changes. See #14973.
MINOR BREAKING CHANGE (ui): The view collection (focusables) required by FocusCycler#constructor() must only contain views implementing the FocusableView interface. Failing to do so will result in a TypeScript error. If your custom code creates FocusCycler instances, please make sure that all views passed in focusables implement the focus() method. See #14973.
MINOR BREAKING CHANGE (ui): The font size of the FormHeaderView component has been increased. This change affects the look of Find and replace and Table styling features as well as custom user interfaces that use this component. See #14973.
MINOR BREAKING CHANGE (ui): The type of AriaLiveAnnouncerPoliteness has been changed (previously enum, now a constant object). See #14973.
MINOR BREAKING CHANGE (ui): The #next and #previous properties of a FocusCycler will now point to the same view if there is only one focusable view (previously null). This change may affect integrations that use this helper to manage advanced focus navigation in dynamic UIs. See #14973.


Additional information

Requires https://github.com/cksource/ckeditor5-commercial/pull/5720.

oleq added 30 commits August 10, 2023 14:02
…iews. Brought support for focus cycling integration with child views.
… entire Dialog a DraggableView. Improved performance of the DraggableViewMixin.
…and simplify dialog creation for most integrators.
… ensure dialogs don't obscure the panel if not positioned manually.
packages/ckeditor5-editor-classic/src/classiceditorui.ts Outdated Show resolved Hide resolved
packages/ckeditor5-editor-classic/src/classiceditorui.ts Outdated Show resolved Hide resolved
packages/ckeditor5-ui/src/dialog/dialog.ts Outdated Show resolved Hide resolved
packages/ckeditor5-ui/src/dialog/dialog.ts Outdated Show resolved Hide resolved
packages/ckeditor5-ui/src/dialog/dialog.ts Outdated Show resolved Hide resolved
packages/ckeditor5-ui/src/dialog/dialogview.ts Outdated Show resolved Hide resolved
packages/ckeditor5-ui/src/focuscycler.ts Outdated Show resolved Hide resolved
packages/ckeditor5-editor-classic/src/classiceditorui.ts Outdated Show resolved Hide resolved

/**
* Moves the dialog view to the off-screen position.
* Used when there's no space to display the dialog.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this comment. It sounds like we move the dialog off screen when the dialog is too big for the viewport (no space). Did you mean it or did you mean that we move it off screen when there's no correct place to pin the dialog to (e.g. no root or something)?

packages/ckeditor5-ui/src/dialog/dialogview.ts Outdated Show resolved Hide resolved
packages/ckeditor5-ui/src/dialog/dialogview.ts Outdated Show resolved Hide resolved

this.moveTo( leftCoordinate, domRootRect.top + defaultOffset );
} else {
this._moveOffScreen();
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about that 🤔, did we discuss it? When there can be no domRootRect (I can imagine no root in the editor, something else?) Then, if there's no domRootRect, shouldn't we use screen center or close it instead moving off screen? 🤔

I think I get it -- this can happen if the dialog is pinned to a part of the dom root and we scroll so the dom root is no longer visible, then you move the dialog off the screen. But in this case... does it really make sense? Why not keep the dialog where it was?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's consistent with other UI parts like dropdowns or balloons, but I don't really know if there's a reason for it - cc @oleq

Comment on lines +138 to +141
// This logic handles cases when textarea has been hidden while changes were made to its content but they could not
// be reflected to its height (auto-grown) because it was invisible or detached from DOM. The auto-grow logic
// gets executed as soon as the textarea becomes visible again.
this._resizeObserver = new ResizeObserver( this.element!, evt => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I tried to figure out why we ended up with this solution and why we need ResizeObserver for this. It is used only for the case described in the comment, which made me even more confusing.

In principle, what we want to do is: when the textarea becomes visible, we want to auto-resize it (as it's value may have changed while it was not visible).

But why we need ResizeObserver for that? AFAIR -- we don't have a precise way to observe when given element becomes visible/hidden if it is done outside of editor's control. However, I assume that ResizeObserver detects that, because when something gets hidden/visible its size becomes 0/non-0.

Is this correct?

If yes, then please change the comment so it describes what we want to achieve in simpler words and why we need ResizeObserver for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the context - the root cause for the whole change was to simplify the code in AI Assistant (https://github.com/cksource/ckeditor5-commercial/pull/5832#discussion_r1426461711). We didn't want to make people use the additional listener to reset their components before dialog is hidden, and onHide effectively works as afterHide. Hence we're making the Textarea responsible for detecting when it can resize itself.

I added more elaborate comment explaining the generic issue.

scofalik and others added 2 commits January 8, 2024 16:55
…collection

Other (ui): `FocusCycler`'s `#focusables` collection should only contain `FocusableView` instances. Closes #14973.

MINOR BREAKING CHANGE (ui): The view collection `focusables` required by [`FocusCycler#constructor()`](https://ckeditor.com/docs/ckeditor5/latest/api/module_ui_focuscycler-FocusCycler.html#function-constructor) must only contain views implementing the [`FocusableView`](https://ckeditor.com/docs/ckeditor5/latest/api/module_ui_focuscycler-FocusableView.html) interface. Failing to do so will result in a TypeScript error. If your custom code creates `FocusCycler` instances, please make sure that all views passed in `focusables` implement the `focus()` method.
…if that's the only focusable view (#15623)

Internal (ui): `FocusCycler#next` and `#previous` should point to the same view even if that's the only focusable view to allow for easier nested cyclers' integration. Previously they were set to `null`.
@scofalik scofalik marked this pull request as ready for review January 9, 2024 12:02
@scofalik scofalik merged commit f8e2b1c into master Jan 9, 2024
3 of 6 checks passed
@scofalik scofalik deleted the ck/14973-dialogs branch January 9, 2024 12:13
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.

Dialog/modal system for the CKEditor 5
5 participants