Angular HTML Component Refactor causes compatibility issues with BS4 classes

Currently, I am working on Angular components and I have a specific section that I would like to refactor into a separate component for reusability. Initially, when the HTML block with only Bootstrap 4 classes is placed in the parent component, the user interface displays correctly.

However, upon refactoring this section into another component, the UI breaks even though it contains only Bootstrap 4 classes.

I have experimented with different versions of ViewEncapsulation, but it has not resolved the issue. Despite setting ViewEncapsulation.None and inspecting the developer tools in Chrome, there appear to be additional classes attached to the component selector.

I am unsure of what I may be overlooking, as the classes utilized are standard Bootstrap 4 classes. It is perplexing why the UI breaks in this scenario.

Answer №1

Following up on my previous comment, please take a look at this stackblitz example;

  • The first form matches your initial screenshot.
  • The second form corresponds to your second screenshot - the key issue mentioned in your question was caused by duplicating the same class col-[xx]-4 used in form #1.
  • The third form is the solution I suggested... now that skills are in a separate component, we should use col-[xx]-12 as the class within it.

I hope this explanation is helpful. If not, feel free to fork the stackblitz and provide your feedback here in the comments.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a React prop type validation that is dependent on the value of another prop

I am in the process of creating a custom React Table component, with the following TableProps structure: export interface ColumnType<ItemType, Key extends keyof ItemType = keyof ItemType> { header: string; key?: keyof ItemType; renderCell: (val ...

tips for aligning items in the center with angular flexbox

I'm attempting to create an Angular Material application using the angular flex layout as shown in this demo. Despite trying different configurations, I can't seem to get it right. My goal is to have multiple cards under a toolbar that take up ab ...

Template for typed variable - `ng-template`

How can the parent component correctly identify the type of let-content that is coming from ngTemplateOutletContext? The current usage of {{content.type}} works as expected, but my IDE is showing: unresolved variable type Is there a way to specify the ...

Create a TypeScript view component that encapsulates an HTMLElement for seamless integration with TweenMax

Looking to develop my own basic view component class that encompasses an HTMLElement or JQuery element, I want to be able to do something similar to this: var newComponent:CustomComponent = new CustomComponent($('#someDiv')); TweenMax.to(newCom ...

Tips for implementing a method to switch CSS properties of a main container by using a checkbox within its child element in a Svelte component

It took me a while to figure this out, but I still feel like my implementation is not ideal. I'm confused as to why things break when I remove the checkedActivities.has(activity) ? "checked" : "unchecked", because I thought TypeScr ...

What is the reason for my Firestore listener consistently retrieving data from the server despite having offline persistence enabled?

Incorporating Firebase JavaScript Modular Web Version 9 SDK into my Vue 3 / TypeScript application. My understanding is that when utilizing real-time listeners with offline persistence in Firestore, the process should proceed as follows: Upon initializat ...

When working with Expo and React Native in TypeScript, VS code IntelliSense recommends using 'react-native/types' instead of just 'react-native'

My React Native TypeScript setup is showing react-native/types instead of react-native in IntelliSense. How can I fix this issue? I initialized my project using npx create-expo-app MyApp --template Typescript. Here is my tsconfig.json configuration. { ...

The schematic "library" was not located within the collection "@schematics/angular"

While attempting to create a library in Angular CLI, I encountered the following error: Schematic "library" not found in collection "@schematics/angular". Error: Schematic "library" not found in collection "@schematics/angular". at SchematicEngine.cre ...

There was an issue when attempting to create a unique component with the TAB feature in Angular Material

Looking to implement a custom TAB component using Angular Material 9. Here is the code snippet for creating a TAB with Angular Material: <mat-tab-group> <mat-tab label="First"> Content 1 </mat-tab> <mat-tab label=" ...

Steps for reverting the version of angular cli from 1.0.1 to 1.0.0

Hey there, I'm struggling to deploy my app due to the version of angular-cli. After checking, I found that my angular-cli version is: @angular/common: 2.4.10 @angular/compiler: 2.4.10 @angular/core: 2.4.10 @angular/forms: 2.4.10 @angular/http: 2.4.1 ...

In a standalone script, the error message "ReferenceError: exports is not defined in ES module scope" is encountered

When I execute the script using npx ts-node -i --esm --skipProject -T .\seed.ts import { readdir, readFile } from "node:fs/promises" async function readFeedsFromFiles() { const data = await readdir("./seedData/feeds", { ...

Can a decorator be added to a Typescript class after it has been created?

Is it possible to update a class with inversify's @injectable decorator after it has been created? My use case involves using a mocking library like ts-auto-mock to generate a mock for me, and then applying the @injectable decorator to bind the mock t ...

Is casting performed by <ClassName> in typescript?

According to the Angular DI documentation, there is an example provided: let mockService = <HeroService> {getHeroes: () => expectedHeroes } So, my question is - can we consider mockService as an instance of HeroService at this point? To provide ...

Angular navigation did not work as expected

Created a basic webpage using Angular CLI version 8.3. The issue is as follows: For example: www.domainname.com is working fine. www.domainname.com/basicprinciples will work if visited through the main page, but it does not work when directly visiting w ...

Ways to expand media queries using sass

I have been using media queries to modify my code. @media (min-width: 576px) .modal-dialog { max-width: 500px; margin: 14% auto; } I want to change the media query, but after searching online, I couldn't find a suitable solution. I know the foll ...

The array used within the useEffect hook and the getCoordinates function appears to be distinct when printed with console

Utilizing GoogleMap API for Custom Location Display I have an imported array of JSON objects named data which includes an address property. The Google Maps API is used to retrieve coordinates from the addresses in order to generate custom markers displaye ...

Deriving union type in Typescript from values within a module or object

I'm trying to find a method similar to keyof typeof myModule in typescript. However, instead of a union of key strings, I need a union of the value types. I have a module with an increasing number of exports - myModule.ts: export const Thing1; expor ...

Transferring Information in Angular 8 between components on the Same Level

Currently utilizing Angular 8 with two independent components. One component contains a form with an ID field, and the other is accessed by clicking a button from the first component. The second component does not display simultaneously with the first. A ...

Deleting a property once the page has finished loading

My issue is a bit tricky to describe, but essentially I have noticed a CSS attribute being added to my div tag that seems to come from a node module. The problem is, I can't seem to find where this attribute is coming from in my files. This attribute ...

The element is inferred to have an 'any' type due to the fact that a 'string' type expression cannot be used to access elements in the type '{ Categories: Element; Admin: Element; }'

As someone who is new to TypeScript, I am trying to understand why I am encountering a type error in the code below (simplified): "use client"; import { ArrowDownWideNarrow, Settings } from "lucide-react"; interface LinkItemProps { ...