Skip to content

fix: do not set placeholder to empty string by default - #7573

Merged
web-padawan merged 5 commits into
mainfrom
fix/mscb-placeholder-empty
Jul 25, 2024
Merged

web-padawan merged 5 commits into
mainfrom
fix/mscb-placeholder-empty

Conversation

@web-padawan

Copy link
Copy Markdown
Member

Description

Fixes #7551

Changed to align with InputControlMixin by removing default empty string value, so that we don't have placeholder attribute set by default. Also fixed the logic for restoring placeholder property in selected items observer.

Note, the property has reflectToAttribute so technically setting empty string can still cause that to happen (which is the case for all input fields). I don't think we can easily fix that without a breaking change.

Type of change

  • Bugfix

@web-padawan
web-padawan requested a review from vursen July 19, 2024 08:18
@vursen

vursen commented Jul 22, 2024 •

Copy link
Copy Markdown
Contributor

Looks like the change results in a regression: after deselecting all items, the original placeholder doesn't come back, and instead, the placeholder shows the last deselected item.

Screen.Recording.2024-07-22.at.12.27.53.mov
<vaadin-multi-select-combo-box placeholder="Placeholder"></vaadin-multi-select-combo-box>

<script>
  const comboBox = document.querySelector('vaadin-multi-select-combo-box');
  comboBox.items = ['Item 1'];
  comboBox.selectedItems = ['Item 1'];
</script>

@web-padawan

Copy link
Copy Markdown
Member Author

Looks like the change results in a regression: after deselecting all items, the original placeholder doesn't come back

Thanks, this actually is related to the fact that in your example (and the dev page) we use <script> without type set to module (and therefore both placeholder and selectedItems are set before the component gets upgraded.

Added a fix for this case and updated tests to reproduce it (by replacing fixtureSync() usage with manual adding to DOM).

@vursen

vursen commented Jul 22, 2024 •

Copy link
Copy Markdown
Contributor

Added a fix for this case and updated tests to reproduce it

Looks like this didn't fix the regression completely. When deselecting all items without an initial placeholder, the placeholder doesn't clear and shows the last deselected item again.

<vaadin-multi-select-combo-box></vaadin-multi-select-combo-box>

<script>
  const comboBox = document.querySelector('vaadin-multi-select-combo-box');
  comboBox.items = ['Item 1'];
  comboBox.selectedItems = ['Item 1'];
</script>

@web-padawan

Copy link
Copy Markdown
Member Author

When deselecting all items without an initial placeholder, the placeholder doesn't clear

Thanks, fixed and added a test with setting placeholder to undefined.

@sonarqubecloud

sonarqubecloud Bot commented Jul 24, 2024 •

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 24.5.0.alpha6 and is also targeting the upcoming stable 24.5.0 version.

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.

Multi-select-combo-box placeholder attribute active when no placeholder text set

3 participants