Skip to content

Conversation

@KamikX
Copy link

@KamikX KamikX commented Nov 1, 2024

add Knowledge base - usage with third party libraries section with Select2 example

@bocharsky-bw
Copy link
Member

Do you refer to any known issue or PR with these changes?

Copy link
Member

@bocharsky-bw bocharsky-bw left a comment

Choose a reason for hiding this comment

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

I think we should explain in short what that code does. I mean, why we need that code (and seems you explained it before the code block) and what this code should do? Should it trigger that "change event" on some specific select2 events?

If you're using [Select2](https://select2.org/) that is instantiated on the page load, you may need to wrap it in a Stimulus controller to make it work when new fields dynamically pop up into your HTML DOM.
Example: [Symfony UX Turbo](https://symfony.com/bundles/ux-turbo/current/index.html#decomposing-complex-pages-with-turbo-frames) + [Custom stimulus controller](https://stimulus.hotwired.dev/reference/controllers)

**_select2_controller.js_**
Copy link
Member

Choose a reason for hiding this comment

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

No need in this as the file name along with the path is specified in the code block itself

this.select.select2('destroy');
}

bindOnSelect2Event(select2) {
Copy link
Member

Choose a reason for hiding this comment

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

I would move this method after initBaseSelector() for better readability

Comment on lines +293 to +295
allowClear: {type: Boolean, default: false},
placeholder: {type: String, default: null},
closeOnSelect: {type: Boolean, default: true}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe group bool types together? Like:

Suggested change
allowClear: {type: Boolean, default: false},
placeholder: {type: String, default: null},
closeOnSelect: {type: Boolean, default: true}
placeholder: {type: String, default: null},
allowClear: {type: Boolean, default: false},
closeOnSelect: {type: Boolean, default: true},
@weaverryan
Copy link
Contributor

weaverryan commented Nov 6, 2024

Hi @KamikX!

Thanks for the contribution! After talking it over, we're not going to merge this as we feel it falls too far outside of the scope. However, this PR is now findable and this would be a great addition to something like StackOverflow.

Cheers!

@weaverryan weaverryan closed this Nov 6, 2024
@KamikX
Copy link
Author

KamikX commented Nov 9, 2024

Do you refer to any known issue or PR with these changes?

PR refer to this issue and your suggestio.

@bocharsky-bw
Copy link
Member

Thanks for sharing the cross-link! Now it will be easier to find your code snippet for others on GitHub 👍

@bocharsky-bw bocharsky-bw changed the title update README.md [docs] Code snippet example about how to use Select2 with this bundle Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants