Skip to content

alignment is wrong when isHidden is set to true for Text inside ActionButton with icon #4946

@prabirshrestha

Description

@prabirshrestha

Provide a general summary of the issue here

For responsive design I would like to remove <Text> when in mobile view but show it when in larger screens.

🤔 Expected Behavior?

Correct alignment.

image

😯 Current Behavior

left padding is bigger than the right instead of center aligned.

image

💁 Possible Solution

isHidden should be respected for now I'm using the following workaround.

export const useInBaseReponsiveMode = () => {
  const { matchedBreakpoints } = useBreakpoint();
  const isBase = useMemo(() => {
    return getResponsiveProp(
      {
        base: true,
        M: false,
      },
      matchedBreakpoints
    );
  }, [matchedBreakpoints]);
  return isBase;
};

return (
  <ActionButton>
    <Add />
    {!isBase && <Text>New</Text>}
  </ActionButton>
);

Seems like a hack.

🔦 Context

No response

🖥️ Steps to Reproduce

Set isHidden for ActionButton and resize the window.

<ActionButton>
  <Add />
  <Text isHidden={{ base: true, M: false }}>New</Text>
</ActionButton>

Version

3.29.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

linux

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions