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

IBX-4767: Input_text updated extrabutton #682

Merged
merged 8 commits into from
Jan 25, 2023

Conversation

Gengar-i
Copy link
Contributor

@Gengar-i Gengar-i commented Jan 18, 2023

Question Answer
JIRA issue IBX-4767
Type bug
Target Ibexa DXP version 4.4.0
BC breaks no
Doc needed no

Added input_text updated with extrabutton

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Checked that target branch is set correctly (main for features, the oldest supported for bugs).

@Gengar-i Gengar-i changed the title IBX-4767 input_text updated extrabutton, alert added new variant IBX-4767: Input_text updated extrabutton, alert added new variant Jan 18, 2023

extraBtns.forEach((btn) => {
const input = btn.closest('.ibexa-input-text-wrapper').querySelector('input');
const clearButton = btn.previousElementSibling;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use of previousElementSibling is error-prone: it is enough to insert some other element in between, and previousElementSibling no longer will be a clear button. Remembering about this will be hard thus it should be changed to something more precise.

src/bundle/Resources/public/scss/_alerts.scss Outdated Show resolved Hide resolved
const clearButton = btn.previousElementSibling;
const clearButtonStyles = global.getComputedStyle(clearButton);
const clearButtonMarginRight = parseInt(clearButtonStyles.getPropertyValue('margin-right'), 10);
const clearButtonWidth = parseInt(clearButtonStyles.getPropertyValue('width'), 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

width might not be an integer, but float.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Than padding also will be float I think :D

const clearButtonMarginRight = parseInt(clearButtonStyles.getPropertyValue('margin-right'), 10);
const clearButtonWidth = parseInt(clearButtonStyles.getPropertyValue('width'), 10);

if (!input && clearButton.classList.contains('ibexa-input-text-wrapper__action-btn--clear')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just question: why we are checking this condition? When input can be null? Under what condition clear button will not have ibexa-input-text-wrapper__action-btn--clear class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as u said in comments above previousElementSibling now I am sure it will be this element I want

Copy link
Contributor

Choose a reason for hiding this comment

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

But you are assigning previousElementSibling to a variable which says it is the clear button. So from that perspective, it does not make sense to check whether the clear button has ibexa-input-text-wrapper__action-btn--clear.
Why we are checking whether input is falsy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since input is not required I am checking if its exist
I fixed the clearButton issue


const paddingRight = `${btn.offsetWidth + clearButtonMarginRight + clearButtonWidth}px`;

btn.disabled = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure whether disabled should be handled globally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
btn.disabled = true;
btn.disabled = !input.value;

Maybe this way?

Copy link
Contributor

Choose a reason for hiding this comment

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

What if someone wants to add the extra button which is not disabled when input is empty?

@Gengar-i Gengar-i changed the title IBX-4767: Input_text updated extrabutton, alert added new variant IBX-4767: Input_text updated extrabutton Jan 23, 2023
@Gengar-i Gengar-i force-pushed the ibx-4767-product-collection-block branch from 84acaf5 to 0a16ade Compare January 24, 2023 12:04
@sonarcloud
Copy link

sonarcloud bot commented Jan 24, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@tomaszszopinski tomaszszopinski left a comment

Choose a reason for hiding this comment

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

QA approved on IbexaDXP 4.4 commerce.

@dew326 dew326 merged commit caa5d24 into main Jan 25, 2023
@dew326 dew326 deleted the ibx-4767-product-collection-block branch January 25, 2023 08:37
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.

8 participants