Skip to content

Allow BBBHint to be an uncontrolled component #29

@Arthurk12

Description

@Arthurk12

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

Currently, BBBHint requires consumers to manage external state (e.g. useState) just to control the open/close behavior. This is verbose and unnecessary for simple use cases where the default behavior — closing when the X button is clicked — is already sufficient.

Describe the solution you'd like

BBBHint should infer uncontrolled mode when no open or onClose props are provided. In that case, clicking the X button should automatically close the hint without requiring any external state in the consumer.

Describe alternatives you've considered

Keep the current fully controlled behavior and document a helper hook (e.g. useBBBHintState) that wraps useState to reduce boilerplate. However, this would still require extra code on the consumer side.

Affected component

BBBHint

Proposed API / Usage Example

// Uncontrolled mode — no external state needed
<BBBHint content="Important tip!">
  <BBBButton>Help</BBBButton>
</BBBHint>

// Controlled mode still works as expected
const [open, setOpen] = useState(false);
<BBBHint open={open} onClose={() => setOpen(false)} content="Important tip!">
  <BBBButton>Help</BBBButton>
</BBBHint>

Additional context

The change must be backward compatible. The current controlled behavior should continue to work normally when open and onClose are provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions