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

Make existing dropdowns initialize their panel content on first open #12890

Closed
Tracked by #12592
Reinmar opened this issue Nov 21, 2022 · 9 comments · Fixed by #13066
Closed
Tracked by #12592

Make existing dropdowns initialize their panel content on first open #12890

Reinmar opened this issue Nov 21, 2022 · 9 comments · Fixed by #13066
Assignees
Labels
domain:performance This issue reports a problem or potential improvement regarding editor performance. domain:ui/ux This issue reports a problem related to UI or UX. follow-up:how-to package:table package:ui package:widget squad:core Issue to be handled by the Core team. support:2 An issue reported by a commercially licensed client. type:task This issue reports a chore (non-production change) and other types of "todos".

Comments

@Reinmar
Copy link
Member

Reinmar commented Nov 21, 2022

Part of #12592. Research in #12682.

PoC in ck/12682-performance-reference...ck/12682-performance-lazy-init.

Scope:

  • Check with @oleq whether the change is fine.
  • Make existing UI components (dropdowns, widget toolbar repository, table cell and table props balloons) create their content on demand (this is – on first show).
    • Scope: Most of that was already proposed in the PoC linked above. Let's not search for more types of UI – we got enough already. Additionally, we have many dropdowns that are parts of UI that is loaded on demand anyway (e.g. ones deep inside the table cell props panel), so optimizing them make no sense. The downside of this will be that we'll have two types of dropdowns: optimized and not optimized.
    • Note: In cases where changing the code to use deferred initialization will turn out to significantly increase the complexity or require a larger refactoring of that part of the code, we can safely abort. It's not crucial to have all places changed as many of them will not have any visible impact on performance.
    • Note: Tests will need to be updated.
  • Review existing documentation and align with our code changes:
@Reinmar Reinmar added type:task This issue reports a chore (non-production change) and other types of "todos". package:ui package:widget package:table domain:ui/ux This issue reports a problem related to UI or UX. squad:core Issue to be handled by the Core team. domain:performance This issue reports a problem or potential improvement regarding editor performance. labels Nov 21, 2022
@oleq
Copy link
Member

oleq commented Nov 24, 2022

My 2c regarding ck/12682-performance-reference...ck/12682-performance-lazy-init#diff-5848ac0a8fcb5189cbf784a5a29e686ce98406901539650cee81f0a473df2c03R77-R81:

dropdownView.on( 'change:isOpen', ( evt, name, isOpen ) => {
				if ( isOpen && !dropdownView.listView ) {

can be simplified into

dropdownView.once( 'change:isOpen', () => {

because every dropdown is closed when created

@CKEditorBot CKEditorBot added the status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. label Nov 30, 2022
@martynawierzbicka martynawierzbicka added the support:2 An issue reported by a commercially licensed client. label Dec 5, 2022
@niegowski niegowski self-assigned this Dec 7, 2022
@CKEditorBot CKEditorBot added status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. and removed status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. labels Dec 7, 2022
@niegowski
Copy link
Contributor

This case is not so simple, the ContextualBalloon#view is referenced on init in the following places (before showing code uses view.element to init clickOutsideHandler()):

  • ImageTextAlternativeUI
  • MentionUI
  • LinkUI
  • WidgetToolbarRepository (this might be not an issue)
  • BalloonToolbar (this might be not an issue)
  • TableCellPropertiesUI and TablePropertiesUI is already deferred by postponing panel view creation.

@oleq
Copy link
Member

oleq commented Dec 8, 2022

This case is not so simple, the ContextualBalloon#view is referenced on init in the following places (before showing code uses view.element to init clickOutsideHandler()):

Looks like it comes down to clickOutsideHandler initialization in most cases

clickOutsideHandler( {
emitter: this._mentionsView,
activator: () => this._isUIVisible,
contextElements: [ this._balloon.view.element ],
callback: () => this._hideUIAndRemoveMarker()
} );

We could probably make contextElements a callback and work around this problem.

@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Jan 9, 2023
@CKEditorBot CKEditorBot added this to the iteration 60 milestone Jan 9, 2023
@TobiasHartlehnert
Copy link

TobiasHartlehnert commented Jun 2, 2023

The "minor" breaking changes for release v36.0.0 state that you have to "make sure that you access the dropdown panel/toolbar items after the dropdown is open/the toolbar is visible.

Well, how exactly can this be done? It would be nice to have some examples in the update guide for v36.x. Custom plugins of our build need to listen to the submit-event of LinkUI.formView or manipulate the listView of dropdown buttons, for example. And this should only happen once, I obviously don't want to bind events everytime a view is opened or manipulate a listView everytime it is shown.

@Witoso
Copy link
Member

Witoso commented Jun 5, 2023

@niegowski I think we had somewhere an example but I'm not sure. Does it ring any bells on your side?

@niegowski
Copy link
Contributor

@Witoso maybe you are looking for this? #4836 (comment)

@TobiasHartlehnert
Copy link

@Witoso maybe you are looking for this? #4836 (comment)

Thanks, listening to change:visibleView of ContextualBalloon works great. I figured this would be the solution, just wasn't sure if this is best practice in this scenario.

Now, this seems to work only for toolbars that are triggered by actions inside the editable, i.e. clicking on links or images. When clicking a button in the main editor toolbar that opens a dropdown (like the headings dropdown from the HeadingUI), change:visibleView of ContextualBalloon is not triggered. I need to now when the buttons of theses dropdowns are initially rendered/visible. What would be the correct emitter and event in this case?

@niegowski
Copy link
Contributor

Maybe this will help with dropdowns:

if ( dropdownView.isOpen ) {
addToolbarToOpenDropdown( dropdownView, buttonsOrCallback, options );
} else {
dropdownView.once(
'change:isOpen',

I tested it in some manual test where the first toolbar item is a headings dropdown:

editor.ui.view.toolbar.items.first.once( 'change:isOpen', ( { source } ) => console.log( source.listView ) )

So more generic it would be:

dropdownView.once( 'change:isOpen', ( { source } ) => console.log( source.listView ) )

@TobiasHartlehnert
Copy link

Thanks, works great, too! Appreciate the quick help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:performance This issue reports a problem or potential improvement regarding editor performance. domain:ui/ux This issue reports a problem related to UI or UX. follow-up:how-to package:table package:ui package:widget squad:core Issue to be handled by the Core team. support:2 An issue reported by a commercially licensed client. type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants