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

Add oui-displayNone CSS utility #773

Closed
BSFishy opened this issue May 23, 2023 · 2 comments · Fixed by #1120
Closed

Add oui-displayNone CSS utility #773

BSFishy opened this issue May 23, 2023 · 2 comments · Fixed by #1120
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@BSFishy
Copy link
Contributor

BSFishy commented May 23, 2023

Is your feature request related to a problem? Please describe.

Currently, there is no way to apply display: none in OUI. This is important for scenarios when we need access to the DOM elements without actually showing them. For example:

const ref = useRef(null);
const [show, setShow] = useState(false);

useEffect(() => {
  // populate ref with DOM elements after some lengthy operation

  setShow(true);
}, [ref]);

return (
  <div ref={ref} style={{ display: show ? 'block' : 'none' }} />
);

Describe the solution you'd like

The simplest and cleanest way to achieve this would be to add a new CSS utility class called oui-displayNone. This would be the same as the other display utilities, but with display set to none.

Other display utilities:

// Display
.oui-displayBlock {display: block !important;}
.oui-displayInline {display: inline !important;}
.oui-displayInlineBlock {display: inline-block !important;}

Proposed new utility:

.oui-displayNone {display: none !important;}

Describe alternatives you've considered

I also considered creating a utility component to achieve this. It might look something like this:

return (
  <OuiConditionalRender condition={/* boolean value */}>
    {/* content that is display: none when condition is false */}
  </OuiConditionalRender>
);

However, given the simplicity of the need, I think having an entire component for this would be extremely overkill and not worth the maintaining effort.

Additional context

This gap was identified in an OUI compliance audit: opensearch-project/OpenSearch-Dashboards#4122

@BSFishy BSFishy added the enhancement New feature or request label May 23, 2023
@BSFishy BSFishy removed the untriaged label May 23, 2023
@BSFishy BSFishy moved this to Todo in Look & Feel May 23, 2023
@joshuarrrr joshuarrrr added the good first issue Good for newcomers label Oct 10, 2023
@ShatilKhan
Copy link
Contributor

I'd like to work on this
I've raised PR for my currently assigned issue on OUI

@ShatilKhan
Copy link
Contributor

PR is up

@github-project-automation github-project-automation bot moved this from Todo to Done in Look & Feel Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants