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

Cannot 'unfloat' field labels #688

Closed
jhickman opened this issue Aug 9, 2022 · 3 comments
Closed

Cannot 'unfloat' field labels #688

jhickman opened this issue Aug 9, 2022 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jhickman
Copy link

jhickman commented Aug 9, 2022

Describe the bug
I have a theme that needs the field labels to always float. Looks like this:
image

So, in an entryPoint, I configure this default behavior with this:

public void onModuleLoad() {
  DominoUIConfig.INSTANCE.setFloatLabels(true);
}

However, there are times that I need certain fields to not float labels (for any input that may not have a label). When I try to create with .nonfloating() or setFloating(false) it doesn't do anything (the floating css class stays on the element).

TextBox.create()
  .nonfloating()
  .setPlaceholder("Enter value here")

Looking at the code, I believe I have found the issue. When .setFloating(true) is called, it sets the boolean field permaFloating to true. And with my setup, the constructor will set this to true due to the DominoUIConfig.

In nonfloating(), it first calls unfloatLabel() which checks the permaFloating value; and since it's true, it'll just return without removing the 'floating' css style. However, the nonfloating() next line is this.permaFloating = false, which means in order to turn off floating, i have to call .nonfloating() twice. The following code is the work around

TextBox.create()
  .nonfloating()
  .nonfloating()
  .setPlaceholder("Enter value here")
@jhickman
Copy link
Author

jhickman commented Aug 9, 2022

Maybe I need to understand the floating label mechanism a bit more, and maybe this should be partly a feature request instead. The bug is still there for sure, but I think I'm looking for a different bit of behavior.

When I turn off the floating (where it removes the '.floating' css class), it removes the placeholder, and adds the floating style back when the field is focused; thus causing issues with my layout when tabbing/clicking into textboxes.

What would be best for me is some class (or lack of a class) when there is/isn't a element added. CSS doesn't support parent selectors, and the :has selector is in CSS v4 spec, so that's not available either.

@vegegoku
Copy link
Member

vegegoku commented Aug 9, 2022

Or maybe we redo the css so that the css class is on the label element itself instead of the parent.. 🤔

@jhickman
Copy link
Author

jhickman commented Aug 9, 2022

The solution I had to go with was just to add a marker css class to the field and avoid the nonfloating altogether. Made it a bit simpler

@vegegoku vegegoku self-assigned this Nov 28, 2022
@vegegoku vegegoku added the bug Something isn't working label Nov 28, 2022
@vegegoku vegegoku added this to the 1.0.0-RC15 milestone Nov 28, 2022
vegegoku added a commit that referenced this issue Nov 28, 2022
vegegoku added a commit that referenced this issue Nov 28, 2022
vegegoku added a commit that referenced this issue Nov 28, 2022
vegegoku added a commit that referenced this issue Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants