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

Update highlightFirstItem to take tags in to consideration #5812

Merged
merged 4 commits into from Jan 22, 2021

Conversation

martincarlin87
Copy link
Contributor

This pull request includes a

  • Bug fix
  • New feature
  • Translation

The following changes were made:

  • Update Results.prototype.highlightFirstItem to check for unselected options and if the tags option is set. If so, highlight this first instead of a previously selected option.

This works at the moment when no tags exist, but not when there are existing selected tags.

Fix

image

Current

image

@kevin-brown
Copy link
Member

I've been thinking about this one for the last 9 days and I think the solution I'm aiming to go for is instead of modifying Result to check for tags, is to add a new decorator that is injected when tags is enabled that overrides this method to provide this extra functionality.

@martincarlin87
Copy link
Contributor Author

No problem, sounds like a neater way of doing it 👍

@stale
Copy link

stale bot commented Jul 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Jul 4, 2020
@stale stale bot closed this Jul 12, 2020
@kevin-brown
Copy link
Member

Reopening as a reminder about the decorator plan since I don't see an attached ticket.

Martin Carlin and others added 2 commits January 22, 2021 10:07
This switches the implementation to use a decorator which is only
added when the `tags` option is set during initialization.
Functionally it has no change on the effect but it allows for the
logic to be more isolated. In the end it just keeps it more organized
and works towards cutting back on what is included in the core results.

This also changes the call for setting the `select2-data-tag` attribute
to properly set the attribute as a string instead of relying on the
boolean to string conversion.
@kevin-brown kevin-brown merged commit af79c80 into select2:develop Jan 22, 2021
anttikuuskoski pushed a commit to anttikuuskoski/select2 that referenced this pull request Mar 29, 2022
…t2#5812)

* refactor: check for unselected options when using tags and highlight that option first

* Switch to using a decorator for highlighting tags

This switches the implementation to use a decorator which is only
added when the `tags` option is set during initialization.
Functionally it has no change on the effect but it allows for the
logic to be more isolated. In the end it just keeps it more organized
and works towards cutting back on what is included in the core results.

This also changes the call for setting the `select2-data-tag` attribute
to properly set the attribute as a string instead of relying on the
boolean to string conversion.

* Fix tabbing in newly added decorator

* Add tests for tag focusing in results

Co-authored-by: Kevin Brown <kevin@kevin-brown.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants